Project

General

Profile

Actions

Feature #3085

closed

Time dumping/loading using Psych

Added by tomonacci (Tomo Kazahaya) over 14 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
[ruby-core:29233]

Description

=begin
Due to the precision of timestamp that Psych dumps, dumped time loaded
by Psych is not always identical to the original time.

require 'psych'

time = Time.at(Time.now.sec)
p time == (Psych.load Psych.dump time) #=> true

time = Time.now
p time == (Psych.load Psych.dump time) #=> false (in my environment)

time = Time.at(Time.now.sec, Rational(1, 3))
p time == (Psych.load Psych.dump time) #=> false

According to the YAML timestamp specification [http://yaml.org/type/timestamp.html],
the standard format cannot represent time in rational.
Thus, to fully express Ruby's Time object, we have to use a format
other than the standard YAML timestamp.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0