Overlooking The Obvious

written by nap on September 14th, 2007 @ 09:23 AM

Sometimes we overlook the obvious. This had me scratching my head for a good 15 minutes yesterday. I'll blame it on the plague (aka nasty cold) that I seem to have contracted.

>> format = "%A, %B %d %Y"
=> "%A, %B %d %Y"
>> monday = Time.now.beginning_of_week
=> Mon Sep 10 00:00:00 -0400 2007
>> monday.strftime(format)
=> "Monday, September 10 2007"
>> (monday+6.weeks).strftime(format)
=> "Monday, October 22 2007"
>> (monday+12.weeks).strftime(format)
=> "Sunday, December 02 2007"

Huh? Exactly 12 weeks from Monday is Sunday? WTF?

>> monday + 12.weeks
=> Sun Dec 02 23:00:00 -0500 2007
>> (monday + 12.weeks).dst?
=> false
>> monday.dst?
=> true

Three letters: D S T. Heh.

Comments are closed