From: "NARUSE, Yui" Date: 2010-04-05T13:50:28+09:00 Subject: [ruby-core:29261] Re: [Bug #3085] Time dumping/loading using Psych 2010/4/5 Tanaka Akira : > 2010/4/5 Aaron Patterson : >> >> How should this problem be fixed? �If a time object when dumped as YAML >> does not use the YAML time format, that would be surprising to me. �Is >> my assumption wrong? �I'd like to leave it the way it works now. > > If the fractional seconds are representable in the decimal system, > it should be representable in the YAML time format. > > For example, Ruby obtains the current time using clock_gettime if available. > clock_gettime returns struct timespec which has nano-second resolution. > It needs 9 digits to preserve the information. > But psych dumps only 6 digits. > This is why Psych.load(Psych.dump(Time.now)) doesn't round trip. > > FreeBSD has bintime which is 2**(-64) second resolution. > It is also representable in the decimal system. > (It may need 64 digits, though.) > Ruby generates such time in Socket::AncillaryData#timestamp. YAML's timestamp (ISO 8601)'s fraction can have non-limited digits. http://yaml.org/type/timestamp.html -- NARUSE, Yui naruse@airemix.jp