• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calendar Program  RSS feed

 
Kevin Fonner
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am building a calendar program and I am having some trouble with the design of the repeating events. If I make an event happen on the first day of the month that aint so tuff, however if they want the event to show up on their calendar every 2 weeks... would you have to take the first day it was scheduled and calculate it all the way to the future?
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how are you storing your days (array, hashmap...)?
i am thinking that you could build the calendar by "weeks" rather than "days" so it would be easier to figure out recurring events... each week could have 7 "days" and the days would be assigned actual numerical date values. i do not think the actual numerical dates need to be the focus of the calendar.
just a thought.
 
frank davis
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Greg Harris:
how are you storing your days (array, hashmap...)?

i am thinking that you could build the calendar by "weeks" rather than "days" so it would be easier to figure out recurring events... each week could have 7 "days" and the days would be assigned actual numerical date values. i do not think the actual numerical dates need to be the focus of the calendar.

just a thought.


There must be a simple, elegant way to create a displayable calendar, yet I haven't seen it yet. Doing a search on the internet I found a few examples that hardcode number of days in month and month names by puting them in arrays. Other languages seem to have more built-in support for this type of displayable calendar building. Is Java missing some needed functions or am I missing something?
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java has a Calendar class (java.util), which is not the easiest of things to use. I expect that Kevin is already using that.

IMO the most efficient way of storing the repeating events would be to store a base date and an offset. Then, each time the user changes the view, e.g. by selecting the next month or whatever, you would calculate which days in that month the event falls on.

You can't realistically calculate every date in the future for a repeating event unless you put an arbitrary limit on your calendar.

Does that help at all?

Jules
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!