-
Notifications
You must be signed in to change notification settings - Fork 4
/
183.txt
481 lines (330 loc) · 17.1 KB
/
183.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
[23] [DFN[Unix time]] は、 [[Unix]] 系システムを中心に多くの[[計算機システム]]で用いられている[[日時]]の内部表現形式 ([[整数時刻系]]) です。
[[計算機システム]]用の[[時刻系]]としては最も著名なものです。
* 意味
[25] [[Unix time]] は、
[[元期]][TIME[1970年1月1日0時0分0秒 (UTC)][0]] ([DFN[Unix epoch]]、[DFN[The Epoch]])
から経過した[[秒]]単位の[[時間]]を[[数]]として表したものです。
* 負
[7] [[負]]の値 (1969年以前) は、環境や文脈によっては扱えないことがあります。
最近は多くの環境が[[負]]の値も扱えるようになっているようです。
* 秒未満
[37] [[秒未満]]も含めた[[小数]] ([[浮動小数点数]]) に拡張されていることがあります。
* 閏秒
[15] [[閏秒]]は考えません。
;; [[閏秒のない時刻系]]参照。
* 各言語・プロトコルの Unix time
** C と POSIX
[6] [[C]] には [DFN[time_t]] [[型]]があり、普通 [[Unix time]] を表すものとして扱われています。
[11] [[Perl]] は [CODE[time]] などで[[システム]]の[[時刻]]を使っており、
ほとんどの[[システム]]で [[Unix time]] です。 [[Unix time]]
は [[Perl]] [[アプリケーション]]の標準の内部時刻形式と考えられています。
[38] [[Perl]] の [CODE[[[Time::HiRes]]::[[time]]]] は[[小数]]の [[Unix time]]
を返します。
[REFS[
- [18] [CITE[Definitions]]
( ([TIME[2014-05-13 04:24:34 +09:00]] 版))
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_150>
- [10] [CITE[General Concepts]]
([TIME[2016-04-26 12:24:41 +09:00]] 版)
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_15>
]REFS]
** gzip の時刻
[55] [[gzip]] の [[MTIME]] は、 [[Unix time]] を[[小エンディアン]]の
4バイト[[符号無し整数]]で表したものです。
[56] ただし、[N[0]] は[[タイムスタンプ]]なしを表します。
** PGP の時刻
[FIG(quote)[
[FIGCAPTION[
[5] [CITE@en[RFC 4880 - OpenPGP Message Format]]
([TIME[2015-04-05 14:41:03 +09:00]] 版)
<https://tools.ietf.org/html/rfc4880#section-3.5>
]FIGCAPTION]
> A time field is an unsigned four-octet number containing the number
of seconds elapsed since midnight, 1 January 1970 UTC.
]FIG]
** DKIM の時刻
[13]
[[RFC 4871]] が定義する [CODE(822)@en[[[DKIM-Signature]]:]]
[[頭欄]]の [CODE(822)@en[[[t]]=]] [[タグ]]の値は、
1970年1月1日0時0分0秒 ([[UTC]]) からの[[秒]]数とされています。
ただし、[[閏秒]]は数えません。 [[RFC 4871]] は、
実装に対して最低 10[SUP[12]] (≒ [[紀元後]]20万年、≒ 40ビット[[符号無し整数]])
までの値を扱えることを[['''推奨''']] ([['''SHOULD''']]) しています。
更に、[[サービス拒否攻撃]]防止のために、
12桁以上の値は[[無限大]]とみなして[['''構わない''']]
([['''MAY''']]) ともしています。
** SQL
[31] [[SQL]] では[[時間帯を持たない日時]]の[[データ型]]が使われることも多いですが、
その場合でも [[Unix time]] が使われることがあります。ここでの [[Unix time]]
は、本来の [TIME[1970年1月1日0時 UTC][0]] からの[[秒数]]ではなく、
[[地方時]]の[TIME[0時][00:00:00]]からの[[秒数]]とされています。
[20] [[MySQL]] では、 [CODE[UNIX_TIMESTAMP]] で[[日時]]を [[Unix time]] に、
[CODE[FROM_UNIXTIME]] で [[Unix time]] を[[日時]]に変換できます。
;; [32] [[SQLの日時形式]]も参照。
** OAuth の時刻
[2] [CODE(URI)@en[[[oauth_timestamp]]]] も [[Unix time]] 同等の定義となっています。
** OpenID の時刻
[FIG(quote)[
[FIGCAPTION[
[3] [CITE@en[Final: OpenID Connect Core 1.0 incorporating errata set 1]]
([TIME[2014-11-09 04:00:29 +09:00]] 版)
<http://openid.net/specs/openid-connect-core-1_0.html#rfc.section.2>
]FIGCAPTION]
> Its value is a JSON number representing the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date/time.
]FIG]
** CDNI の時刻
[FIG(quote)[
[FIGCAPTION[
[21] [CITE@en[RFC 8006 - Content Delivery Network Interconnection (CDNI) Metadata]]
([TIME[2016-12-14 14:55:04 +09:00]])
<https://tools.ietf.org/html/rfc8006#section-4.3.4>
]FIGCAPTION]
> A time value expressed in seconds since the UNIX epoch (i.e., zero
hours, zero minutes, zero seconds, on January 1, 1970) Coordinated
Universal Time (UTC) '''['''POSIX''']'''.
> Type: Integer
> Example time representing 09:00:00 01/01/2000 UTC:
946717200
]FIG]
[FIG(quote)[
[FIGCAPTION[
[22] [CITE@en[RFC 8007 - Content Delivery Network Interconnection (CDNI) Control Interface / Triggers]]
([TIME[2016-12-14 14:58:50 +09:00]])
<https://tools.ietf.org/html/rfc8007#section-5.2.5>
]FIGCAPTION]
> A JSON number, seconds since the UNIX epoch (00:00:00 UTC on
1 January 1970).
]FIG]
** TLS の時刻
[FIG(quote)[
[FIGCAPTION[
[4] [CITE@en[RFC 5246 - The Transport Layer Security (TLS) Protocol Version 1.2]]
([TIME[2015-02-19 08:58:15 +09:00]] 版)
<http://tools.ietf.org/html/rfc5246#section-7.4.1.2>
]FIGCAPTION]
>
:gmt_unix_time:
The current time and date in standard UNIX 32-bit format
(seconds since the midnight starting Jan 1, 1970, UTC, ignoring
leap seconds) according to the sender's internal clock. Clocks
are not required to be set correctly by the basic TLS protocol;
higher-level or application protocols may define additional
requirements. Note that, for historical reasons, the data
element is named using GMT, the predecessor of the current
worldwide time base, UTC.
]FIG]
* [DFN[Java時刻]]、[DFN[JavaScript時刻]]
[14] [[Java]] の [CODE[Calendar]] [SRC[>>27]] や
[[JavaScript]] の [CODE(JS)@en[[[Date]]]] の値も [[Unix time]]
と同じ[[元期]]ですが、[[ミリ秒]][[単位]]となっています。 (こちらも[[閏秒]]は考えません。)
[24] [[DOM]] の[[日時]]を扱う [[API]] ([CODE[DOMTimeStamp]]) も、
[[ミリ秒]]単位の千倍 [[Unix time]] を用いています。
;; [45] [[JavaScriptの日時形式]]も参照。
[46]
[[DateTime Wire Format]] でも使われています。
[REFS[
[FIG(quote)[
[FIGCAPTION[
[27] [CITE@en[Calendar (Java Platform SE 7 )]]
([TIME[2014-02-20 11:18:28 +09:00]])
<http://docs.oracle.com/javase/jp/7/api/java/util/Calendar.html>
]FIGCAPTION]
> 特定の時点は、1970 年 1 月 1 日 00:00:00.000 GMT (グレゴリオ暦) を元期とするミリ秒単位のオフセットで表現できます。
]FIG]
]REFS]
* [DFN[Go時刻]]
[34] [[Go]] の [DFN[[CODE[Time][Time (Go)]]]] は、[[ナノ秒]]単位の [[Unix time]]
を用いています。
[REFS[
[FIG(quote)[
[FIGCAPTION[
[33] [CITE[time - The Go Programming Language]]
([TIME[2017-03-10 18:17:34 +09:00]])
<https://golang.org/pkg/time/#Time>
]FIGCAPTION]
> The zero value of type Time is January 1, year 1, 00:00:00.000000000 UTC.
]FIG]
]REFS]
* 桁溢れ問題
[59] [SEE[ [[2038年問題]] ]]
* 関連
[47]
[[PTP]] の[[元期]]も同じく[TIME[1970年1月1日0時][1970-01-01T00:00:00]]ですが、
[[TAI]] を使っているので [[Unix time]] とは少しずれています。
* メモ
[1] ''スラッシュドット ジャパン | 明日でepochから2^30秒'' <http://slashdot.jp/article.pl?sid=04/01/08/172200&mode=flat&commentsort=4&threshold=-1>
[16] [CITE@ja[time_t - Wikipedia]]
( ([TIME[2014-04-22 06:59:21 +09:00]] 版))
<http://ja.wikipedia.org/wiki/Time_t>
[17] [CITE@en[Unix time - Wikipedia, the free encyclopedia]]
( ([TIME[2014-05-11 13:26:43 +09:00]] 版))
<http://en.wikipedia.org/wiki/Unix_time>
[8] [CITE@ja[iPhoneを「1970年1月1日」に設定すると利用不能になる問題、Appleがソフト更新で解消へ - ITmedia ニュース]]
([TIME[2016-02-17 19:58:04 +09:00]] 版)
<http://www.itmedia.co.jp/news/articles/1602/16/news132.html>
[9] [CITE@ja[iPhoneで「1970年1月1日」に設定すると使用不能に? 実際に試してみた - ITmedia Mobile]]
([TIME[2016-02-17 19:59:19 +09:00]] 版)
<http://www.itmedia.co.jp/mobile/articles/1602/12/news125.html>
[19] [CITE@en[WebDriver]]
([TIME[2016-07-22 07:24:31 +09:00]])
<https://w3c.github.io/webdriver/webdriver-spec.html#dfn-unix-epoch>
[FIG(quote)[
[FIGCAPTION[
[26] [CITE@ja[電子機器の時刻]]
([TIME[2017-01-09 16:22:34 +09:00]])
<http://www.ffortune.net/calen/calen/etime.htm>
]FIGCAPTION]
> 2001年9月9日1時46分40秒にこの数字が十進数で9桁から10桁に変わりました。2chなどではこの数字を掲示板のidに使用しているため、この前後での掲示板の並べ替えがうまく行きません。
]FIG]
[FIG(quote)[
[FIGCAPTION[
[28] ([TIME[2001-11-11 14:06:55 +09:00]])
<http://cr.yp.to/proto/utctai.html>
]FIGCAPTION]
> What is the epoch? Originally it was defined as the beginning of 1970 GMT. GMT, Greenwich Mean Time, is a traditional term for the time zone in England. Unfortunately, it is ambiguous; it can refer to a variety of astronomical time scales.
> Arthur David Olson's popular time library uses an epoch of 1970-01-01 00:00:10 TAI.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[29] [CITE[perlvms - search.cpan.org]]
([TIME[2017-02-13 00:40:55 +09:00]])
<http://search.cpan.org/dist/perl/pod/perlvms.pod#time>
]FIGCAPTION]
> The value returned by time is the offset in seconds from 01-JAN-1970 00:00:00 (just like the CRTL's times() routine), in order to make life easier for code coming in from the POSIX/Unix world.
]FIG]
[30] [CITE@en[File API]]
([TIME[2017-02-11 03:25:10 +09:00]])
<https://w3c.github.io/FileAPI/#UnixEpoch>
[FIG(quote)[
[FIGCAPTION[
[35] [CITE[time - The Go Programming Language]]
([TIME[2017-03-10 18:22:09 +09:00]])
<https://golang.org/pkg/time/#Time.UnixNano>
]FIGCAPTION]
> UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC.
]FIG]
[36] [CITE@en[SANS Digital Forensics and Incident Response Blog | Understanding EXT4 (Part 2): Timestamps | SANS Institute]]
([TIME[2017-03-10 19:07:34 +09:00]])
<https://digital-forensics.sans.org/blog/2011/03/14/digital-forensics-understanding-ext4-part-2-timestamps>
[39] [CITE@en[Add PushSubscription.expirationTime (#248)]]
([[beverloo]]著, [TIME[2017-04-19 02:15:13 +09:00]])
<https://github.com/w3c/push-api/commit/73da6411aac80de7de9bf5e65ee8eb4cc6a9aa24>
[40] [CITE@en[Epoch (astronomy) - Wikipedia]]
([TIME[2017-05-08 07:11:20 +09:00]])
<https://en.wikipedia.org/wiki/Epoch_(astronomy)>
[41] [CITE[General Concepts]]
([TIME[2017-05-15 17:06:25 +09:00]])
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_16>
[FIG(quote)[
[FIGCAPTION[
[42] [CITE@en[RFC 7519 - JSON Web Token (JWT)]]
([TIME[2017-05-14 16:14:20 +09:00]])
<https://tools.ietf.org/html/rfc7519#section-2>
]FIGCAPTION]
> NumericDate
> A JSON numeric value representing the number of seconds from
> 1970-01-01T00:00:00Z UTC until the specified UTC date/time,
> ignoring leap seconds. This is equivalent to the IEEE Std 1003.1,
> 2013 Edition '''['''POSIX.1''']''' definition "Seconds Since the Epoch", in
> which each day is accounted for by exactly 86400 seconds, other
> than that non-integer values can be represented.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[43] [CITE@en[RFC 7049 - Concise Binary Object Representation (CBOR)]]
([TIME[2017-05-07 16:11:09 +09:00]])
<https://tools.ietf.org/html/rfc7049#section-2.4.1>
]FIGCAPTION]
> Tag value 1 is for numerical representation of seconds relative to
> 1970-01-01T00:00Z in UTC time. (For the non-negative values that the
> Portable Operating System Interface (POSIX) defines, the number of
> seconds is counted in the same way as for POSIX "seconds since the
> epoch" '''['''TIME_T''']'''.) The tagged item can be a positive or negative
> integer (major types 0 and 1), or a floating-point number (major type
> 7 with additional information 25, 26, or 27). Note that the number
> can be negative (time before 1970-01-01T00:00Z) and, if a floating-
> point number, indicate fractional seconds.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[44] [CITE@en[レシートのフィールド]]
([TIME[2017-05-18 00:39:47 +09:00]])
<https://developer.apple.com/jp/documentation/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html>
]FIGCAPTION]
> 定期購読の有効期限が、1970年1月1日 00:00:00 GMTからのミリ秒単位で表されています。
> ASN.1フィールドタイプ:1708
> ASN.1フィールド値: IA5STRING(RFC 3339の日付として解釈されます)
> JSONフィールド名:expires_date
> JSONフィールド値:数値
]FIG]
[FIG(quote)[
[FIGCAPTION[
[48] [CITE@ja[プログラマーの常識をJavaで身につける(4):OSとプログラミングの「時間」に関する常識 (1/3) - @IT]]
([TIME[2017-06-08 18:49:20 +09:00]])
<http://www.atmarkit.co.jp/ait/articles/0703/28/news135.html>
]FIGCAPTION]
> 具体的には、1970年1月1日 00:00:00 GMTからのミリ秒数を表すlong値として表現されています。この原稿では、これを便宜的に「エポックからのミリ秒」と呼ぶことにします。なお、1970年1月1日 00:00:00 GMTについてJava言語APIでは、「エポック」と呼んでいます。
]FIG]
[FIG(quote)[
[FIGCAPTION[
[49] [CITE[日付関数またはタイムスタンプ関数の日付部分 - Amazon Redshift]]
([TIME[2017-06-08 07:42:07 +09:00]])
<http://docs.aws.amazon.com/ja_jp/redshift/latest/dg/r_Dateparts_for_datetime_functions.html>
]FIGCAPTION]
> Amazon Redshift の EPOCH の実装は、サーバーのあるタイムゾーンから独立した 1970-01-01 00:00:00.000000 に関連します。
]FIG]
[FIG(quote)[
[FIGCAPTION[
[50] [CITE@ja-jp[タイムスタンプ型 | CQL for Cassandra 2.x]]
([TIME[2017-05-23 01:28:12 +09:00]])
<https://docs.datastax.com/ja/cql-jajp/3.1/cql/cql_reference/timestamp_type_r.html>
]FIGCAPTION]
> タイムスタンプ型の値は64ビットの符号付き整数としてエンコードされ、エポックとして知られる標準基準時間(1970年1月1日、GMT時間0時0分0秒)からのミリ秒数を表します。
]FIG]
[FIG(quote)[
[FIGCAPTION[
[51] [CITE@en[GitHub API v3 | GitHub Developer Guide]]
([TIME[2017-06-10 05:53:45 +09:00]])
<https://developer.github.com/v3/#rate-limiting>
]FIGCAPTION]
> The time at which the current rate limit window resets in UTC epoch seconds.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[52] [CITE@en[docker service logs | Docker Documentation]]
([TIME[2017-06-10 10:22:13 +09:00]])
<https://docs.docker.com/engine/reference/commandline/service_logs/#extended-description>
]FIGCAPTION]
> When providing Unix timestamps enter seconds'''['''.nanoseconds''']''', where seconds is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a fraction of a second no more than nine digits long.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[53] [CITE[取引所APIドキュメント | Coincheck(コインチェック)]]
([TIME[2017-06-22 11:12:30 +09:00]])
<https://coincheck.com/ja/documents/exchange/api>
]FIGCAPTION]
> ACCESS-NONCE 毎リクエストごとに増加する必要のある正の整数。通常はUNIXタイムスタンプを用います。最大値は 9223372036854775807 です。APIキーごとに管理されます。
]FIG]
[54] [CITE@en[Make Event's timeStamp use DOMHighResTimeStamp]]
([[majido]]著, [TIME[2017-07-13 16:38:55 +09:00]])
<https://github.com/whatwg/dom/commit/912d58746bc4c67c2fd210124639f7c34991fce5>
[FIG(quote)[
[FIGCAPTION[
[57] [CITE@en[Git - git-commit Documentation]]
([TIME[2018-03-04 14:30:18 +09:00]])
<https://git-scm.com/docs/git-commit#_date_formats>
]FIGCAPTION]
> Git internal format
> It is <unix timestamp> <time zone offset>, where <unix timestamp> is the number of seconds since the UNIX epoch. <time zone offset> is a positive or negative offset from UTC. For example CET (which is 1 hour ahead of UTC) is +0100.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[58] [CITE@en[Concise Binary Object Representation (CBOR)]]
([TIME[2018-02-23 07:30:37 +09:00]])
<https://cbor-wg.github.io/CBORbis/#datetimesect>
]FIGCAPTION]
> Tag value 1 is for numerical representation of seconds relative to 1970-01-01T00:00Z in UTC time. (For the non-negative values that the Portable Operating System Interface (POSIX) defines, the number of seconds is counted in the same way as for POSIX “seconds since the epoch” '''['''TIME_T''']'''.) The tagged item can be a positive or negative integer (major types 0 and 1), or a floating-point number (major type 7 with additional information 25, 26, or 27). Note that the number can be negative (time before 1970-01-01T00:00Z) and, if a floating-point number, indicate fractional seconds.
]FIG]
[60] [CITE@en[Unix time - Wikipedia]]
([TIME[2018-09-29 18:11:15 +09:00]])
<https://en.wikipedia.org/wiki/Unix_time>