Created
December 11, 2011 17:18
-
-
Save fjfish/1461638 to your computer and use it in GitHub Desktop.
Converting a JSON string date into a Ruby Time object
This file contains 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
# Convert string of the form 2011-12-31T23:59:59+00:00 to a Ruby Time object | |
# I'm sure there's an easier way to do this. | |
def self.json_to_ruby_time(the_string) | |
string_elements = the_string.split /[-T:+]+/ | |
string_elements.pop | |
Time.new *(string_elements.map(&:to_i)) | |
end |
caius
commented
Dec 11, 2011
Too many braces @caius.
Heh, just gave him the same response on Facebook @cauis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment