[9] 
[DFN[DOSの日時形式]]は、
[[FAT]]、
[[ZIP]]、
[[LHA]]
などで用いられています。

;; [11] [[DOS]] は現在となってはほとんど使われていませんが、
小型[[ストレージ]]の[[ファイルシステム]]として [[FAT]]
がまだ生き残っており、
[[ZIP]] も広く用いられています。

;; [12] [[NTFS]] では[[別形式][Windows時間]]が使われています。


- [18] 最小値 : [TIME[1980-01-01T00:00:00]] [[地方時]]
- [19] 最大値 : [TIME[2107-12:31T23:59:58]] [[地方時]] (1980 + 128 - 1)
- [20] 刻み幅 : 2s
- [21] [[時間帯]] : [[地方時]]のみ ([[時差]]記述不可)
- [22] ただし[[日時構成要素]]の[[ビット欄]]の集合体なので、各[[日時構成要素]]の[[値域]]から外れた[[非妥当日時]]も記述できてしまう

* 非妥当日時

[25] [[DOSの日時形式]]で記述できる[[非妥当日時]] :

- [26] [[月]] : [N[0]], [N[13]] - [N[15]]
- [27] [[日]] : [N[0]], 存在しない [N[29]], [N[30]], [N[31]]
- [28] [[時]] : [N[24]] - [N[31]]
- [32] [[分]] : [N[60]] - [N[63]]
- [33] [[2秒]] : [N[30]] (= [N[60]] [[秒]]), [N[31]] (= [N[62]] [[秒]])

;; [34] [[DOSの日時形式]]が表すのは[[閏秒のない時刻系]]です。


[37] 
[[非妥当日時]]を成り行きとする実装 :

[REFS[

- [41] [CITE@en[fat-date/src/index.js at master · desaroger/fat-date · GitHub]], [TIME[2026-01-02T09:28:37.000Z]] <https://github.com/desaroger/fat-date/blob/master/src/index.js>
- [46] 
[CITE@en[fs/fat/misc.c - kernel/common - Git at Google]], [TIME[2026-01-02T09:40:36.000Z]] <https://android.googlesource.com/kernel/common/%2B/88b912e02d75b/fs/fat/misc.c>
-- [47] ほぼ成り行き、ただし0月と0日は1月と1日に読み替え、13月[[以上]]は1月相当
-- [42] [CITE[Bug in date converting functions DOS<=>UNIX in FAT and SMBFS drivers]], [TIME[2026-01-02T10:04:49.000Z]] <https://mail-archive.com/search?l=linux-kernel%40vger.kernel.org&q=Bug+in+date+converting+functions+DOS%3C%3D%3EUNIX+in+FAT+and+SMBFS+drivers&submit.x=0&submit.y=0>
--- [48] 
[CITE@en['''['''PATCH''']''' Bug in date converting functions DOS<=>UNIX in FAT and SMBFS drivers]], [TIME[2026-01-02T10:05:07.000Z]] <https://mail-archive.com/linux-kernel@vger.kernel.org/msg18967.html>

]REFS]

;; [38] 「成り行き」は[[プラットフォーム]]の[[日時データ型]]の[[メソッド]]呼び出しなどに還元される場合もあり、
単純延長だったりエラーだったり結果はいろいろです。

[35] 
[[非妥当日付]]をエラーとする実装 :

[REFS[

- [36] 
[CITE@en[dfdatetime.fat_date_time — dfDateTime 20251125 documentation]], [TIME[2025-11-25T13:36:24.000Z]], [TIME[2026-01-02T07:29:42.027Z]] <https://dfdatetime.readthedocs.io/en/latest/_modules/dfdatetime/fat_date_time.html>
- [39] 
[CITE@en[fat-date-time/src/lib.rs at main · jgerrish/fat-date-time · GitHub]], [TIME[2026-01-02T09:26:03.000Z]] <https://github.com/jgerrish/fat-date-time/blob/main/src/lib.rs>
-- [40] [N[29]], [N[30]], [N[31]] 日の非妥当性は成り行き、それ以外はエラー
- [217] 
[[Perlモジュール]] [CODE[Archive::Zip]]

]REFS]

** 値 [N[0]]

[44] [N[0]] は [TIME[1980-00-00T00:00:00]] を表します。

[45] [[日時]]未設定の意味 [SRC[>>48]] や[[不具合]]等で発生することがあります。

[REFS[

- [43] 
[CITE@en[Incorrect timestamp on IMGMOUNT disk · Issue #1015 · joncampbell123/dosbox-x]], [TIME[2026-01-02T09:33:20.000Z]] <https://github.com/joncampbell123/dosbox-x/issues/1015>

]REFS]

* 生成

[SEE[ [[ファイルの時刻]] ]]


* 文脈

[24] [[ZIP]] [SEE[ [[ファイルの時刻]] ]]

* 換算

[SEE[ [[ファイルの時刻]] ]]

* メモ


[1] [CITE@en-US[How to recognize different types of timestamps from quite a long way away – The Old New Thing]]
([TIME[2017-03-10 19:16:18 +09:00]])
<https://blogs.msdn.microsoft.com/oldnewthing/20030905-02/?p=42653/>

[2] [CITE[exFAT: Time Stamp Format]]
([TIME[2016-05-16 21:20:28 +09:00]])
<http://shullich.blogspot.jp/2009/12/time-stamp-format.html>

[FIG(quote)[
[FIGCAPTION[
[3] ([TIME[2017-02-08 23:22:47 +09:00]])
<https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT>
]FIGCAPTION]

> The date and time are encoded in standard MS-DOS format.

]FIG]




[FIG(quote)[
[FIGCAPTION[
[10] [CITE@ja[電子機器の時刻]]
([TIME[2017-01-09 16:20:12 +09:00]])
<http://www.ffortune.net/calen/calen/etime.htm>
]FIGCAPTION]

>  MSDOSのファイル管理システムであるFAT、およびその拡張形式であるWindows95/98/MeのVFATは更新日時を 年(7bit)月(4bit)日(5bit)時(5bit)分(6bit)秒(5bit)の合計32bitで持っています。秒が0-59のはずなのに5bitしかないのは実は偶数にまるめて記録しているためです。年は7bitで0-127年が記録できますが、FATの起点は1980年なので127は2107年に相当します。つまりFAT/VFATは2107年の年末まで正常に動作します。

]FIG]

[4] [CITE@en[FAT - ForensicsWiki]]
([TIME[2016-11-17 06:18:49 +09:00]])
<http://forensicswiki.org/wiki/FAT#FAT_date_and_time_values>

[5] [CITE[Int 1ah clock service - liangweiqiang]]
([TIME[2017-05-05 04:17:26 +09:00]])
<https://sites.google.com/site/liangweiqiang/Home/e5006/e5006classnote/jumptiming/int1ahclockservice>

[FIG(quote)[
[FIGCAPTION[
[6] [CITE@en[Epoch (reference date) - Wikipedia]]
([TIME[2017-05-09 11:25:26 +09:00]])
<https://en.wikipedia.org/wiki/Epoch_(reference_date)>
]FIGCAPTION]

> January 1, 1980	IBM BIOS INT 1Ah, DOS, OS/2, FAT12, FAT16, FAT32, exFAT  filesystems	The IBM PC with its BIOS as well as 86-DOS, MS-DOS and PC DOS with their FAT12 file system were developed and introduced between 1980 and 1981

]FIG]


[FIG(quote)[
[FIGCAPTION[
[7] [CITE[IROIRO 1999a]]
([TIME[2018-05-19 22:28:39 +09:00]])
<https://web.archive.org/web/20000418193849/http://www.asahi-net.or.jp:80/~ez3k-msym/iroiro99a.htm>
]FIGCAPTION]

> Windows95 で FAT が拡張されたが, 単に長いファイル名が使えるようになっただけでなく, 時刻関連も拡張されている。 古い FAT では最終更新時刻だけを記憶していたが, 新しい FAT ではこれに加えてファイルの作成時刻と最終アクセス時刻も記憶する。 しかし, おかしなことにこの 3つのタイムスタンプはそれぞれ精度が異なる。
> 種類	精度
> 作成時刻	10ミリ秒
> 最終アクセス時刻	1日
> 最終更新時刻	2秒
> このため, Windows95 でファイルの「プロパティ」を見ると, 「作成日時」「更新日時」「アクセス日」と, 最終アクセス時刻だけが「日時」でなく「日」になっている。
> また, ときどき「更新日時」より「作成日時」が 1秒だけ大きいファイルがあるが, これは更新日時が奇数秒のタイムスタンプを持つことができないため 切り捨ててしまったのが原因である。

]FIG]


[FIG(quote)[
[FIGCAPTION[
[8] [CITE@ja-jp[LHAフォーマット ‐ 通信用語の基礎知識]]
([TIME[2018-10-14 01:37:55 +09:00]])
<https://www.wdic.org/w/TECH/LHA%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88>
]FIGCAPTION]

> 0Fh	WORD	ファイルの更新時刻 (MS-DOS形式)
> 11h	WORD	ファイルの更新日付 (MS-DOS形式)

]FIG]


[FIG(quote)[
[FIGCAPTION[
[238] [CITE@ja[UNLHA32.DLLのダウンロード]]
([[Micco]]著, [TIME[2018-06-02 14:14:51 +09:00]])
<https://micco.mars.jp/mysoft/unlha32.htm>
]FIGCAPTION]

> UNLHA32.DLL が通常作成する書庫では, タイムスタンプは, すべて協定世界時 (UTC) で扱われます。 

]FIG]


[13] [CITE['''['''tz''']''' Old timestamps on files]]
([TIME[2018-12-31 22:33:20 +09:00]])
<https://mm.icann.org/pipermail/tz/2018-December/027348.html>


[14] 
[[GPS時間]]や[[SAP S/4HANAの日時]]も[TIME[西暦1980年][1980]]が基準となっています。


[15] [CITE@en[Time formatting and storage bugs - Wikipedia]], [TIME[2023-11-24T03:13:21.000Z]], [TIME[2023-11-25T07:52:30.460Z]] <https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs#Year_2080>

>Systems storing the year as a two-digit value 00..99 internally only, like many RTCs, may roll over from 31 December 2079, to the IBM PC and DOS epoch of 1980-01-01. 

[16] [CITE@en[Time formatting and storage bugs - Wikipedia]], [TIME[2023-11-24T03:13:21.000Z]], [TIME[2023-11-25T07:59:10.350Z]] <https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs#Year_2108>


>The date timestamps stored in FAT filesystems, originally introduced with 86-DOS 0.42 in 25 February 1981 and carried over into MS-DOS, PC DOS, DR-DOS etc., will overflow at the end of 31 December 2107. The last modification date stamp (and with DELWATCH 2.0+ also the file deletion date stamp, and since DOS 7.0+ optionally also the last access date stamp and creation date stamp), are stored in the directory entry with the year represented as an unsigned seven bit number (0–127), relative to 1980, and thereby unable to indicate any dates in the year 2108 and beyond. The API functions defined to retrieve these dates officially only support dates up to 31 December 2099.
>
This will also affect the ZIP archive file format, as it uses FAT file modification timestamps internally. 



[17] [CITE@ja[exFATのタイムゾーン値 - @port139 Blog]], [TIME[2025-05-12T10:17:04.000Z]] <https://port139.hatenablog.com/entry/20100519/1274221533>



[23] 
[CITE@en[linux/fs/fat/misc.c at master · torvalds/linux · GitHub]], [TIME[2026-01-01T08:00:07.000Z]] <https://github.com/torvalds/linux/blob/master/fs/fat/misc.c>
