Can someone help me by summarizing the Marshal format for Time in Ruby
1.8.6?
Here’s what I’ve worked out:
-
The time is always based on the UNIX epoch
-
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
-
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
-
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 :).
Thanks,
-Curt