Debian Codegraph @

docs/sources/Date-and-time-values.md

raw
1 # Date and time values
2 ## Terminology
3
4 **Calendar**: a system of organising days.
5
6 **Epoch**: a reference point from which time is measured.
7
8 **Leap second**: a leap second is a one-second adjustment that is occasionally
9 applied to Coordinated Universal Time (UTC) in order to keep its time of day
10 close to the mean solar time.
11
12 ### Also see
13
14 * [Wikipedia: Calendar](https://en.wikipedia.org/wiki/Calendar)
15 * [Wikipedia: Epoch](https://en.wikipedia.org/wiki/Epoch_(reference_date))
16 * [Wikipedia: Leap second](https://en.wikipedia.org/wiki/Leap_second)
17
18 ## Accuracy and precision
19
20 * **accuracy** is used to describe the closeness of a measurement to the true
21 value;
22 * **precision** is the closeness of agreement among a set of results.
23
24 In NTFS data and time values are stored using a [FILETIME structure](https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime).
25 The FILETIME structure stores a date and time value as a 64-bit integer that
26 represents the number of 100-nanosecond intervals since "January 1, 1601
27 00:00:00.0000000 UTC". This provides an upper bound of a 100-nanosecond
28 interval **data granularity**. For disambiguation we'll refer to this as
29 **datetime storage granularity**.
30
31 However this does not have to mean that the actual value stored within the
32 FILETIME structure has a 100-nanosecond interval data granularity. E.g. the
33 FILETIME MSDN article also mentions that on NTFS, the access time has a
34 **resolution** of 1 hour. For disambiguation the term resolution is comparable
35 with that of [Display resolution](https://en.wikipedia.org/wiki/Display_resolution)
36 or [Audio resolution](https://en.wikipedia.org/wiki/Audio_bit_depth), we'll
37 refer to this as **datetime value granularity**.
38
39 The FILETIME MSDN article also mentions that some values should be interpreted
40 not as date and time values e.g. 0xFFFFFFFF can be used to specify that a
41 file's previous access time should be preserved, or 0 to specify that the date
42 and time value is not set. For disambiguation we'll refer to this as **datetime
43 value semantics** (in other words meaning or representation).
44
45 ### Digital forensics significance
46
47 A large part of digital forensic analysis is about the interpretation of
48 computer data. If date and time values are converted from a storage format to
49 another storage format or a string representation we are likely to change
50 granularity and semantics in the process. If the analyst is aware of this the
51 impact should be minimal, however if we wish to have automation assisted
52 analysis we'll have to preserve concepts of granularity and semantics and
53 represent them in a machine process-able manner. So that the automation can
54 distinguish between a FILETIME date and time value that is not set versus a
55 FILETIME date and time value that represents "January 1, 1601 00:00:00.0000000
56 UTC".
57
58 Another aspect relevant to digital forensic analysis is how to represent a
59 datetime value with a value granularity of 1 day (e.g. FAT access time) in a
60 timeline of microseconds, where the analyst is only interested in the events
61 that occurred within a specific hour on that day. Technically the access time
62 should be included in the resulting timeline since the access could have
63 occurred during that specific hour.
64
65 ### References
66
67 * [Wikipedia: Accuracy and precision](https://en.wikipedia.org/wiki/Accuracy_and_precision)
68 * [Wikipedia: Computer forensics](https://en.wikipedia.org/wiki/Computer_forensics)
69 * [Wikipedia: Granularity - Data and information](https://en.wikipedia.org/wiki/Granularity#Data_and_information)
70 * [Wikipedia: Semantics](https://en.wikipedia.org/wiki/Semantics)
71 * [FILETIME structure](https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime)
72 * [File Times](https://learn.microsoft.com/en-us/windows/win32/sysinfo/file-times)
73 * [Precision and accuracy of DateTime](https://learn.microsoft.com/en-us/archive/blogs/ericlippert/precision-and-accuracy-of-datetime), by Eric Lippert, April 8, 2010
74
75 ## .NET DateTime
76 ### Characteristics
77
78 Attribute | Description
79 --- | ---
80 Supported date range | 0001-01-01 00:00:00 through 9999-12-31 23:59:59
81 Storage granularity | 100 nanoseconds
82 Time zone | externally represented, typically UTC
83
84 ### Format
85
86 Offset | Size | Description
87 --- | --- | ---
88 0 | 4 or 8 | timestamp, little endian integer value containing the number of 100 nanosecond intervals since January 1, 0001 00:00:00.0000000
89
90 ### Also see
91
92 * [Microsoft: DateTime struct](https://learn.microsoft.com/en-us/dotnet/api/system.datetime?view=net-6.0)
93 * [Microsoft: DateTime.Ticks](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.ticks?view=net-8.0)
94
95 ## APFS timestamp
96 ### Characteristics
97
98 Attribute | Description
99 --- | ---
100 Supported date range | 1677-09-21 00:12:43.145224192 through 2262-04-11 23:47:16.854775807
101 Storage granularity | 1 nanosecond
102 Time zone | externally represented, typically UTC
103
104 ### Format
105
106 Offset | Size | Description
107 --- | --- | ---
108 0 | 8 | timestamp, integer value containing the number of nanoseconds before (when negative) or after (when positive) 1970-01-01 00:00:00.000 (or POSIX or Unix epoch)
109
110 ## Cocoa timestamp
111 ### Characteristics
112
113 Attribute | Description
114 --- | ---
115 Supported date range | ...
116 Storage granularity | 1 second with higher granularity in fractional part
117 Time zone | externally represented, typically UTC
118
119 ### Format
120
121 Offset | Size | Description
122 --- | --- | ---
123 0 | 4 or 8 | timestamp, floating point value containing the number of seconds since 2001-01-01 00:00:00
124
125 ### Also see
126
127 * [Apple Developer: Dates](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DatesAndTimes/Articles/dtDates.html)
128 * [Apple Developer: NSDate](https://developer.apple.com/documentation/foundation/nsdate)
129
130 ## Delphi TDateTime
131 ### Characteristics
132
133 Attribute | Description
134 --- | ---
135 Supported date range | ... through 9999-12-31 23:59:59.999
136 Storage granularity | 1 day with higher granularity in fractional part
137 Time zone | externally represented, typically UTC
138
139 ### Format
140
141 Offset | Size | Description
142 --- | --- | ---
143 0 | 4 | timestamp, floating point value containing the number of days since 1899-12-30 00:00:00
144
145 ### Also see
146
147 * Embarcadero Delphi documentation on System.TDateTime
148
149 ## FAT date and time
150 ### Characteristics
151
152 Attribute | Description
153 --- | ---
154 Supported date range | 1980-01-01 00:00:00 through 2107-12-31 23:59:58
155 Storage granularity | 2-second intervals
156 Time zone | externally represented, typically local time
157
158 Sometimes 2099-12-31 23:59:58 is defined as the upper bound of DOS date and
159 time. Also see: [Time formatting and storage bugs - Year 2100](https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs#Year_2100)
160
161 ### Format
162
163 The FAT (or DOS) date is a 16-bit value that consists of:
164
165 Offset | Size | Description
166 --- | --- | ---
167 0.0 | 5 bits | day of month, where 1 is the first day of the month
168 0.5 | 4 bits | month, where January is represented by 1
169 1.1 | 7 bits | year, ranging from 1980 through
170
171 The FAT (or DOS) time is a 16-bit value that consists of:
172
173 Offset | Size | Description
174 --- | --- | ---
175 0.0 | 5 bits | number of 2-second intervals, ranging from 0 through 29
176 0.5 | 6 bits | minutes, ranging from 0 through 59
177 1.2 | 5 bits | hours, ranging from 0 through 23
178
179 ### Also see
180
181 * [Wikipedia: File Allocation Table](https://en.wikipedia.org/wiki/File_Allocation_Table)
182 * [DosDateTimeToFileTime function](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime)
183
184 ## FAT timestamp
185 ### Characteristics
186
187 Attribute | Description
188 --- | ---
189 Supported date range | 1980-01-01 00:00:00.00 through 2107-12-31 23:59:58.99
190 Storage granularity | 10 milliseconds
191 Time zone | externally represented
192
193 ### Format
194
195 Offset | Size | Description
196 --- | --- | ---
197 0 | 8 | timestamp, integer value containing the number of 10 milliseconds intervals after 1980-01-01 00:00:00.00 (or FAT date time epoch)
198
199 ## FILETIME
200 ### Characteristics
201
202 Attribute | Description
203 --- | ---
204 Supported date range | 1601-01-01 00:00:00.0000000 through ...
205 Storage granularity | 100-nanosecond intervals
206 Time zone | externally represented, typically UTC
207
208 The actual upper bound of the supported date range is unclear.
209
210 ### Format
211
212 The FILETIME structure is 8 bytes of size and consists of:
213
214 Offset | Size | Description
215 --- | --- | ---
216 0 | 4 | lower 32-bit of the 64-bit timestamp
217 4 | 4 | upper 32-bit of the 64-bit timestamp
218
219 The FILETIME should be treated as a structure when stored and passed to Windows
220 API functions. However it can be combined into a 64-bit integer, which will be
221 indicated as a FILETIME timestamp, containing the number of seconds since
222 1601-01-01 00:00:00.0000000.
223
224 An empty (or unset) FILETIME timestamp can be represented by 0, however the
225 meaning can differ depending on the context in which the timestamp is used.
226
227 Certain values of FILETIME such as { 0xffffffff, 0xffffffff } for the
228 SetFileTime Windows API function are overloaded with a special meaning.
229
230 ### Also see
231
232 * [MSDN: FILETIME](https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime)
233
234 ## Golang time.Time timestamp
235
236 ### Characteristics
237
238 Attribute | Description
239 --- | ---
240 Supported date range | 0001-01-01 00:00:00.0000000 through ...
241 Storage granularity | 1 nanosecond
242 Time zone | internally represented.
243
244 The granularity of the time zone value depends on the version of the timestamp.
245 Version 1 timestamps are stored in minutes and version 2 timestamps add a
246 seconds component. *Note: Version 2 is currently not supported.*
247
248 ### Format
249
250 Offset | Size | Description
251 --- | --- | ---
252 0 | 1 | version (known values are 1 or 2)
253 1 | 8 | seconds since January, 1, 1 stored as a 64-bit big-endian signed integer
254 9 | 4 | fraction of second, in nanoseconds stored as a 32-bit big-endian signed integer
255 13 | 2 | time zone offset in minutes as a 16-bit big-endian signed integer.
256 15 | 1 | time zone offset in seconds (only for version 2)
257
258 A value of -1 is a special value when the Time instance is initialised as UTC
259 (e.g. ```time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)```).
260
261 ### Also see
262
263 * [Golang time.go](https://cs.opensource.google/go/go/+/master:src/time/time.go)
264
265 ## HFS timestamp
266
267 Sometimes a distinction is made between HFS and HFS+ timestamps is that the
268 former is stored in local time and the latter in UTC. Note that this behavior
269 is highly depending on the context in which the timestamp is used.
270
271 ### Characteristics
272
273 Attribute | Description
274 --- | ---
275 Supported date range | 1904-01-01 00:00:00 through 2040-02-06 06:28:15
276 Storage granularity | 1 second
277 Time zone | externally represented
278
279 ### Format
280
281 Offset | Size | Description
282 --- | --- | ---
283 0 | 4 | timestamp, integer value containing the number of seconds since 1904-01-01 00:00:00
284
285 An empty (or unset) HFS timestamp can be represented by 0, however the meaning
286 can differ depending on the context in which the timestamp is used.
287
288 ### Also see
289
290 * [Wikipedia: HFS Plus](https://en.wikipedia.org/wiki/HFS_Plus)
291 * [Technical Note TN1150 - HFS Plus Volume Format](https://developer.apple.com/library/archive/technotes/tn/tn1150.html), see section "HFS Plus Dates"
292
293 ## Java timestamp
294 ### Characteristics
295
296 Attribute | Description
297 --- | ---
298 Supported date range | ...
299 Storage granularity | 1 millisecond
300 Time zone | externally represented
301
302 ### Format
303
304 Offset | Size | Description
305 --- | --- | ---
306 0 | 8 | timestamp, integer value containing the number of milliseconds before (when negative) or after (when positive) 1970-01-01 00:00:00.000 (or POSIX or Unix epoch)
307
308 ### Also see
309
310 * [Class java.util.Date](https://docs.oracle.com/javase/8/docs/api/java/util/Date.html)
311
312 ## OLE Automated date
313
314 The OLE Automated date is also known as Floatingtime or Application time.
315
316 ### Characteristics
317
318 Attribute | Description
319 --- | ---
320 Supported date range | ...
321 Storage granularity | 1 day with fragment
322 Time zone | externally represented
323
324 ### Format
325
326 Offset | Size | Description
327 --- | --- | ---
328 0 | 8 | timestamp, floating-point value containing the number of days before (when negative) or after (when positive) 1889-12-30. The fractional part represents the fraction of a day since midnight.
329
330 ## POSIX timestamp
331
332 There multiple variants of the POSIX timestamp:
333
334 * the `time_t` has different sizes and signs on different platforms
335 * variants exist that store the timestamp in milliseconds (Java), microsecond and nanoseconds (APFS) precision instead of second precision
336
337 ### Characteristics
338
339 Attribute | Description
340 --- | ---
341 Supported date range | 1901-12-13 20:45:52 through 2038-01-19 03:14:07 (32-bit)
342 Storage granularity | 1 second
343 Time zone | externally represented
344
345 ### Format
346
347 Offset | Size | Description
348 --- | --- | ---
349 0 | 4 or 8 | timestamp, integer value containing the number of seconds before (when negative) or after (when positive) 1970-01-01 00:00:00 (or POSIX or Unix epoch)
350
351 An empty (or unset) POSIX timestamp can be represented by 0, however the
352 meaning can differ depending on the context in which the timestamp is used.
353
354 ### Also see
355
356 * [Wikipedia: UNIX time](https://en.wikipedia.org/wiki/Unix_time)
357
358 ## RFC2579 date-time
359 ### Characteristics
360
361 Attribute | Description
362 --- | ---
363 Supported date range | 0-01-01 00:00:00.0 through 65536-12-31 23:59:59.9
364 Storage granularity | 1 decisecond (100 milliseconds)
365 Time zone | internally represented as [+-]hh:mm from UTC
366
367 ### Format
368
369 The RFC2579 date-time structure is 11 bytes of size and consists of:
370
371 Offset | Size | Description
372 --- | --- | ---
373 0 | 2 | year, ranging from 0 through 65536
374 2 | 1 | month, where January is represented by 1
375 3 | 1 | day of month, where 1 is the first day of the month
376 4 | 1 | hours, ranging from 0 through 23
377 5 | 1 | minutes, ranging from 0 through 59
378 6 | 1 | seconds, ranging from 0 through 59
379 7 | 1 | deciseconds, ranging from 0 through 9
380 8 | 1 | direction from UTC, "+" or "-"
381 9 | 1 | hours from UTC, ranging from 0 through 13
382 10 | 1 | minutes from UTC, ranging from 0 through 59
383
384 ### Also see
385
386 * [RFC2579](https://datatracker.ietf.org/doc/html/rfc2579)
387
388 ## SYSTEMTIME
389 ### Characteristics
390
391 Attribute | Description
392 --- | ---
393 Supported date range | 1601-01-01 00:00:00.000 through 30827-12-31 23:59:59.999
394 Storage granularity | 1 millisecond
395 Time zone | externally represented
396
397 ### Format
398
399 The SYSTEMTIME structure is 16 bytes of size and consists of:
400
401 Offset | Size | Description
402 --- | --- | ---
403 0 | 2 | year, ranging from 1601 through 30827
404 2 | 2 | month, where January is represented by 1
405 4 | 2 | day of week, staring with Sunday represented by 0
406 6 | 2 | day of month, where 1 is the first day of the month
407 8 | 2 | hours, ranging from 0 through 23
408 10 | 2 | minutes, ranging from 0 through 59
409 12 | 2 | seconds, ranging from 0 through 59
410 14 | 2 | milliseconds, ranging from 0 through 999
411
412 An empty (or unset) SYSTEMTIME can be represented by 16x 0-byte values.
413
414 ### Also see
415
416 * [MSDN: SYSTEMTIME](https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-systemtime)
417
418 ## Time element strings
419
420 ### ISO 8601 / RFC 3339
421
422 Example `2020-05-31T00:00:47.044800+00:00`
423
424 ### RFC 822
425
426 Example `Tue, 15 Nov 94 08:12:31 GMT`
427
428 ### RFC 1123
429
430 Example `Tue, 15 Nov 1994 08:12:31 GMT`
431
432 ### RFC 2822
433
434 ### Also see
435
436 * [RFC 822 - Date and time specification](https://datatracker.ietf.org/doc/html/rfc822#section-5)
437 * [RFC 1123 - RFC-822 date and time specification](https://datatracker.ietf.org/doc/html/rfc1123#section-5)
438 * [RFC 2822 - Date and time specification](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3)
439 * [RFC 3339 - Internet date/time format](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6)
440
441 ## UUID version 1 time
442 ### Characteristics
443
444 Attribute | Description
445 --- | ---
446 Supported date range | 1582-10-15 00:00:00.0000000 through ...
447 Storage granularity | 100-nanosecond intervals
448 Time zone | externally represented, typically UTC
449
450 ### Format
451
452 Offset | Size | Description
453 --- | --- | ---
454 0 | 60-bits | integer value, containing the number of 100-nanosecond intervals since 1582-10-15 00:00:00
455 7.4 | 4-bits | version
456 8.0 | 16-bits | UUID version (variant) and clock sequence
457 10.0 | 48-bits | node identifier (typically a MAC address in UUID version 1)
458
459 ### Also see
460
461 * [Wikipedia: Universally unique identifier](https://en.wikipedia.org/wiki/Universally_unique_identifier)
462
463 ## WebKit timestamp
464 ### Characteristics
465
466 Attribute | Description
467 --- | ---
468 Supported date range | ...
469 Storage granularity | 1 microsecond
470 Time zone | externally represented, typically UTC
471
472 ### Format
473
474 Offset | Size | Description
475 --- | --- | ---
476 0 | 8 | timestamp, signed integer value containing the number of microseconds before (when negative) or after (when positive) 1601-01-01 00:00:00.000000
477
478 ### Also see
479
480 * [Chromium source: time.h](https://chromium.googlesource.com/chromium/src/base/+/refs/heads/main/time/time.h#5)