Skip to content

Instantly share code, notes, and snippets.

@vpivo
Created December 4, 2013 09:12
Show Gist options
  • Save vpivo/7784581 to your computer and use it in GitHub Desktop.
Save vpivo/7784581 to your computer and use it in GitHub Desktop.
Time Problem Solution?
1.9.3p448 :015 > j.deadline_at = DateTime.parse('04 Dec 2013 09:30:00' ) <- setting time with DateTime object
=> Wed, 04 Dec 2013 09:30:00 +0000
1.9.3p448 :016 > reload!
Reloading...
=> true
1.9.3p448 :017 > j.deadline_at
=> Wed, 04 Dec 2013 01:30:00 PST -08:00 <- Mongo Mapper assumes it is in UTC, reformats it into a Time object.
1.9.3p448 :018 > j.deadline_at = Time.parse('04 Dec 2013 09:30:00' ) <- setting time with Time
=> 2013-12-04 09:30:00 -0800
1.9.3p448 :019 > j.save!
=> true
1.9.3p448 :020 > reload!
Reloading...
=> true
1.9.3p448 :021 > j.deadline_at
=> Wed, 04 Dec 2013 09:30:00 PST -08:00 <- Since it was already a Time object, Mongo Mapper left it alone and stored it as is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment