[Ironruby-core] Marshal format for Time

Curt Hagenlocher curth at microsoft.com
Tue Sep 16 18:26:43 EDT 2008

In case anyone was wondering, here's a partial decoding:

dword 1, little-endian
bits 0-4: Hour
bits 5-9: Day, 1=1st
bits 10-13: Month, 0=January
bits 14-29: Year, 0=1900
bit 30: 0=Local, 1=Utc.  1.8.6 always writes 0 here
bit 31: 1 to indicate this format

dword 2, little-endian
bits 0-19: Microseconds
bits 20-25: Seconds
bits 26-31: Minutes

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Curt Hagenlocher
Sent: Montag, 15. September 2008 16:52
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Marshal format for Time

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/20080916/1a6a76c8/attachment-0001.html>

More information about the Ironruby-core mailing list