Hmm. Ooh yuck.

Try this...

$ ruby -r time -e 'a=Time.now;p a-Time.parse(a.to_s)'
0.00848
$ ruby -r time -e 'a=Time.now;p a-Time.parse(a.to_s)'
0.446575
$ ruby -r time -e 'a=Time.now;p a-Time.parse(a.to_s)'
0.142796

ie. Time#to_s doesn't represent the full precision of the internal
time format.

Bit of a bummer if you want to round trip an exact timestamp onto disk
and back.

This does it right...
$ ruby -e 'a=Time.now;p a-Marshal::load(Marshal::dump(a))'
0.0


...but look at whats on disk...
ruby -e 'a=Time.now;p Marshal::dump(a)'
"\004\bu:\tTime\rC\347\032\200z\343S\302"

Eeew! Not exactly human friendly.

The following is probably the most elegant way of exactly round
tripping a time to disk and back in a human readable form?

ruby -w -rtime -e 'a=Time.now;b = a.xmlschema(6);p b;p a-Time.xmlschema(b)'
"2007-10-26T17:01:08.129059+13:00"
0.0


Ah well.

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter / tait.co.nz
New Zealand