Chris Richards wrote the following on 24.10.2006 18:04 :
The Time::next_week method is supposed to give the time of the start of
the next week. But look at this, it cocks up :
t=Time.parse "Monday October 16th 2006"
=> Mon Oct 16 00:00:00 BST 2006
=> Mon Oct 23 00:00:00 BST 2006
=> Tue Oct 24 00:00:00 BST 2006
=> Mon Oct 30 00:00:00 GMT 2006
Arrhhhgg!! Its just f*cked up my application data!
This is most probably a timezone related bug and not easily solved IMHO. It seems to me that as in UTC your original date is in fact in the previous week at some point the next_week method forget to take the TZ into account. next_week should probably enforce TZ being consistant across the whole computations (in general this becomes quite tricky when you mix several Time objects with various TZs in the computation).
This isn't applicable to your specific problem, but I take the opportunity to write it there:
The timezone problem being so complex, I only manipulate UTC Time objects (try t.utc, t.utc.next_week, t.utc.next_week.next_week and you'll see the problem doesn't show up) and convert to localtime only when needed. Unfortunately, the next_week result is clearly TZ-dependant so you can't simply switch to UTC.