Created
December 11, 2012 19:12
-
-
Save kalv/4261166 to your computer and use it in GitHub Desktop.
What is going on here?
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
$ ruby -v | |
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0] | |
$ ruby test_time.rb | |
Parsing the timestamp 2012-12-11 18:01:54.246524000 | |
The float compare to string formatted output: false | |
"1355277714.2465239" | |
"1355277714.246524" |
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
require 'rubygems' | |
require 'time' | |
require 'active_support' | |
timestamp_to_parse = "2012-12-11 18:01:54.246524000" | |
puts "Parsing the timestamp #{timestamp_to_parse}" | |
time = Time.parse(timestamp_to_parse) | |
puts "The float compare to string formatted output: #{time.to_f.to_s == time.strftime("%s.%6N")}" | |
p time.to_f.to_s | |
p time.strftime("%s.%6N") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment