[Ironruby-core] Marshal format for Time

Curt Hagenlocher curth at microsoft.com
Mon Sep 15 19:52:04 EDT 2008

Can someone help me by summarizing the Marshal format for Time in Ruby 1.8.6?

Here's what I've worked out:

1)      The time is always based on the UNIX epoch

2)      When the fourth byte is less than 128, it implies some kind of older format.  This format is read but not written

a.       The first four bytes *seem* to represent the standard UNIX time value

3)      When the fourth byte is equal to 128, it implies the "1.8.6 format".  The implications are

a.       The first byte represents number of hours

b.      The second byte represents number of 8-day blocks

c.       The third byte represents 4-year blocks

d.      The eighth byte represents 4-second blocks

e.      Bytes 5-7 represent microseconds as a 3-byte little-endian value

4)      When the fourth byte is greater than 128, or if the byte count is not 8, an error is raised

What I'd like to understand is

a)      How this works with leap years

b)      What kinds of legacy formats are supported, as I seem to be getting inconsistent answers when the fourth byte is less than 128

I'd appreciate any assistance, as this format appears to be totally undocumented.  Please don't post any actual source code, as I would be required by our lawyers to "do an Oedipus" on my eyeballs if I so much as glance at it :).


Curt Hagenlocher
curth at microsoft.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080915/a86f3fb8/attachment.html>

More information about the Ironruby-core mailing list