Created
March 26, 2015 05:10
-
-
Save StephenOTT/fc49f278f094fade10bd to your computer and use it in GitHub Desktop.
Date Conversion for MongoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is a way to deal with this issue: | |
def convertIssueDatesInMongo (issues) | |
issues.each do |y| | |
y["created_at"] = DateTime.strptime(y["created_at"], '%Y-%m-%dT%H:%M:%S%z').to_time.utc | |
y["updated_at"] = DateTime.strptime(y["updated_at"], '%Y-%m-%dT%H:%M:%S%z').to_time.utc | |
end | |
return issues | |
end | |
issues is a Array with a hash inside of it. | |
This example was from dealing with the Github API for the Issues API. | |
Note that "to_time" is only available starting in ruby ~1.9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment