This is a method for dividing up time into differing units of scale, either a constant factor such as binary or a more arbitrary arrangement. This is useful for many things, such as indexing a series of linear events and being able to group them by different levels of temporal granularity.
Due to the implementation, the limit on dates supported is:
1970-01-01 00:00:00 UTC - 2038-01-19 03:14:07 UTC
Standard UNIX time is represented by the number of seconds since epoch, that being the start of January 1, 1970. Positive values indicate points in time after this, and negative values indicate prior to it. This is called a time_t type offset, based on the UNIX time_t data type.
TimeInterval is stored as an unsigned 32-bit number by appropriating the bit usually reserved for indicating a negative value and using it to encode how large or small the interval defined is.
# Defaults to the current time interval = . # Convert to a time grouped by 1<<16 seconds encoded = interval.to_i(16) # Decode this time back into a regular time_t offset, but this will # be rounded to 1<<16 second granularity. decoded = .(encoded)
Copyright © 2010 Scott Tadman, The Working Group