Proposal for new Computer Timestamp Format
April, 2010
This document proposes a a 64-bit unsigned integer format to represent dates and times on a given calendar. It has a number of advantages and is intended as a replacement for old computer timestamp formats. World Code Project implements this timestamp as a part of the World Code Library (WCL).
Since the 64-bit integer is composed of a series of bit fields, WCL timestamps have a range of up to 16384 years, support up to 16 different calendars, and can specify instants in time down to the microsecond.
Unique High Resolution Instances
A WCL timestamp specifies a unique instant in time truncated down to the microsecond (millionth of a second). Therefore, each microsecond is represented by its own unique 64-bit integer (although not all 64-bit integers are valid WCL timestamps).
The special bit format of a WCL timestamp also supports modern calendar adjustment techniques, such as leap seconds and leap days. Even where leap seconds are present, unique 64-bit values are assigned without disrupting time stamp order. This is unlike POSIX compliant timestamps, which always assume the same number of seconds per day, resulting in ambiguous timestamps when leap seconds are present.
Continuity
As should be with any timestamp, WCL timestamps can be sorted in natural date time order by sorting them as unsigned 64-bit integer values (i.e. earlier timestamps always have lower values than later timestamps).
Multiple Calendar Support
WCL timestamps have a bit field that supports up to 16 different calendar systems. Therefore, in multi-national or multi-lingual applications, it’s possible to record high resolution timestamps in a native calendar format.
Currently, conversion algorithms still are necessary to convert between WCL timestamps that were marked different calendars.
Gregorian Calendar Date Range
On the Gregorian Calendar, all time values are specified as Coordinated Universal Time (UTC), which eliminates the need to specify the time zone. Assuming that the modern UTC standard for time is extrapolated far into the past and future, WCL timestamps can specify instances in time as early as January 1, 8191 B.C. at 00:00:00.000000 UTC and as far into the future as December 31 8191 A.D. at 23:59:59.999999 UTC.
Why not Unix time?
Why do we need another timestamp format, when “Unix time” (POSIX compliant) timestamps are widely used? Unix timestamps are good for general purpose use, but several issues exist with their accuracy and range.
Creating a time format that supports every use all of the time, future or past is difficult, at best (see the reasonably accurate depiction of how Unix time has evolved in Wikipedia article at http://en.wikipedia.org/wiki/Unix_time).
The WCL timestamp format overcomes weaknesses in some key areas where we feel that modern computing will benefit:
-
The 2038 Problem – Commonly used 32-bit timestamps cannot specify time past the year 2038. Many enterprise systems get around this by using simply 64-bit timestamps. WCL timetamps also get around this limit with a 64-bit timestamp format.
-
High Resolution Measurements – With high speed computing and modern logging/auditing requirements, a modern timestamp format should support high resolution. In the case of WCL timestamps, 64-bit range allows microsecond resolution.
-
Leap Seconds - Most timestamp formats use a continguous number space, meaning that any leap seconds are not distinguishable from normal seconds. The WCL timestamp uses a slightly non-contiguous space to allow leap seconds to be specified accurately.
-
International Calendar Support – The world is becoming a smaller place. Enterprise systems are increasingly supporting multiple languages and locales. The WCL timestamp supports this need by allowing timestamps to occur on the most commonly used calendar systems.
WCL Timestamp Format:
|
Field |
Bits |
Size |
Description |
Integer Range |
Gregorian Calendar - Valid Range |
Julian Calendar – Valid Range |
|
Calendar |
60-63 |
4 |
Calendar designation
0000 = Gregorian
0001 = Julian
All other values are reserved, to be assigned by WCL. |
0 - 15 |
Bits ‘0000’ specify the Gregorian Calendar |
Bits ‘0001’ specify the Julian Calendar |
|
Epoch |
59 |
1 |
0 = the year is on or after the calendar’s epoch 1 = the year is prior to the calendar’s epoch |
0 or 1 |
0 = A.D. 1 = B.C. |
0 = A.D. 1 = B.C. |
|
Year |
46-58 |
13 |
The year |
0 thru 8192 |
If epoch = 1, year is 1 - 8191 only.
If epoch = 0, year is stored as a twos-compliment value without a sign bit. **See note below
Zero is invalid. |
If epoch = 1, year is 1 - 8191 only.
If epoch = 0, year is stored as a twos-compliment value without a sign bit. **See note below
Zero is invalid. |
|
Month |
42-45 |
4 |
The month |
0 - 15 |
1 - 12 only. Values 0, 13, 14 and 15 are invalid. |
1 - 12 only. Values 0, 13, 14 and 15 are invalid. |
|
Day |
37-41 |
5 |
The day |
0 - 31 |
1 - 31 only. Value 0 is invalid. |
1 - 31 only. Value 0 is invalid. |
|
Day Seconds |
20-36 |
17 |
The number of seconds within the day |
0 thru 131071 |
0 - 86399 typically, but 86400 is allowed if a leap second is present on the given day |
0 - 86399 only. |
|
Micro-seconds |
0-19 |
20 |
The number of microseconds |
0 thru 1048575 |
0 - 999999 only |
0 - 999999 only |