Tyler Knappe wrote: > I'm creating a calendar of sorts which maps events. > > For each event, I know its start and end date/time. I also know the > current date and time. What I need to be able to do is calculate the > start of the week, regardless of the day of the week. > > So, if it is Wednesday and I want to populate my Calendar from Monday - > Sunday with the events, I need to know the date of Monday to start. To > compare absolute days I've converted them to Ruby epoch with the idea of > comparing each day (84600 seconds) versus the end date. If the day is > greater than the end date, I then check the hours of the day to see on > what hour the event occurred.
The code posted is wrong (pulled from a backup file), but I think I see a way to address the problem. If I know the current day of the week, I can find Monday and subtract off for each day of the week past Monday. I just needed to walk away from the problem for a bit to figure it out. :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

