MS-DOS datetime: GraphViz block diagram (.dot) source

MS-DOS date and time are packed 16-bit values that specify local date/time. The time is always stored in the current UTC time offset set on the computer which created the file. Note that the daylight saving time (DST) shifts also change the UTC time offset.

For example, if you pack two files A and B into a ZIP archive, file A last modified at 2020-03-29 00:59 UTC+00:00 (GMT) and file B at 2020-03-29 02:00 UTC+01:00 (BST), the file modification times saved in MS-DOS format in the ZIP file will vary depending on whether the computer packing the files is set to GMT or BST at the time of ZIP creation.

  • If set to GMT:
    • file A: 2020-03-29 00:59 (UTC+00:00)
    • file B: 2020-03-29 01:00 (UTC+00:00)
  • If set to BST:
    • file A: 2020-03-29 01:59 (UTC+01:00)
    • file B: 2020-03-29 02:00 (UTC+01:00)

It follows that you are unable to determine the actual last modified time of any file stored in the ZIP archive, if you don't know the locale time setting of the computer at the time it created the ZIP.

This format is used in some data formats from the MS-DOS era, for example:

KS implementation details

License: CC0-1.0
Minimal Kaitai Struct required: 0.9

References

This page hosts a formal specification of MS-DOS datetime using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

GraphViz block diagram source

dos_datetime.dot

digraph {
	rankdir=LR;
	node [shape=plaintext];
	subgraph cluster__dos_datetime {
		label="DosDatetime";
		graph[style=dotted];

		dos_datetime__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
			<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			<TR><TD PORT="time_pos">0</TD><TD PORT="time_size">2</TD><TD>Time</TD><TD PORT="time_type">time</TD></TR>
			<TR><TD PORT="date_pos">2</TD><TD PORT="date_size">2</TD><TD>Date</TD><TD PORT="date_type">date</TD></TR>
		</TABLE>>];
		subgraph cluster__time {
			label="DosDatetime::Time";
			graph[style=dotted];

			time__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="second_div_2_pos">0</TD><TD PORT="second_div_2_size">5b</TD><TD>b5</TD><TD PORT="second_div_2_type">second_div_2</TD></TR>
				<TR><TD PORT="minute_pos">0:5</TD><TD PORT="minute_size">6b</TD><TD>b6</TD><TD PORT="minute_type">minute</TD></TR>
				<TR><TD PORT="hour_pos">1:3</TD><TD PORT="hour_size">5b</TD><TD>b5</TD><TD PORT="hour_type">hour</TD></TR>
			</TABLE>>];
			time__inst__second [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>second</TD><TD>(2 * second_div_2)</TD></TR>
			</TABLE>>];
			time__inst__padded_second [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>padded_second</TD><TD>(second &lt;= 9 ? &quot;0&quot; : &quot;&quot;) + second.to_s(10)</TD></TR>
			</TABLE>>];
			time__inst__padded_minute [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>padded_minute</TD><TD>(minute &lt;= 9 ? &quot;0&quot; : &quot;&quot;) + minute.to_s(10)</TD></TR>
			</TABLE>>];
			time__inst__padded_hour [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>padded_hour</TD><TD>(hour &lt;= 9 ? &quot;0&quot; : &quot;&quot;) + hour.to_s(10)</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__date {
			label="DosDatetime::Date";
			graph[style=dotted];

			date__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="day_pos">0</TD><TD PORT="day_size">5b</TD><TD>b5</TD><TD PORT="day_type">day</TD></TR>
				<TR><TD PORT="month_pos">0:5</TD><TD PORT="month_size">4b</TD><TD>b4</TD><TD PORT="month_type">month</TD></TR>
				<TR><TD PORT="year_minus_1980_pos">1:1</TD><TD PORT="year_minus_1980_size">7b</TD><TD>b7</TD><TD PORT="year_minus_1980_type">year_minus_1980</TD></TR>
			</TABLE>>];
			date__inst__year [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>year</TD><TD>(1980 + year_minus_1980)</TD></TR>
			</TABLE>>];
			date__inst__padded_day [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>padded_day</TD><TD>(day &lt;= 9 ? &quot;0&quot; : &quot;&quot;) + day.to_s(10)</TD></TR>
			</TABLE>>];
			date__inst__padded_month [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>padded_month</TD><TD>(month &lt;= 9 ? &quot;0&quot; : &quot;&quot;) + month.to_s(10)</TD></TR>
			</TABLE>>];
			date__inst__padded_year [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>padded_year</TD><TD>(year &lt;= 999 ? &quot;0&quot; + (year &lt;= 99 ? &quot;0&quot; + (year &lt;= 9 ? &quot;0&quot; : &quot;&quot;) : &quot;&quot;) : &quot;&quot;) + year.to_s(10)</TD></TR>
			</TABLE>>];
		}
	}
	dos_datetime__seq:time_type -> time__seq [style=bold];
	dos_datetime__seq:date_type -> date__seq [style=bold];
	time__seq:second_div_2_type -> time__inst__second [color="#404040"];
	time__inst__second:second_type -> time__inst__padded_second [color="#404040"];
	time__inst__second:second_type -> time__inst__padded_second [color="#404040"];
	time__seq:minute_type -> time__inst__padded_minute [color="#404040"];
	time__seq:minute_type -> time__inst__padded_minute [color="#404040"];
	time__seq:hour_type -> time__inst__padded_hour [color="#404040"];
	time__seq:hour_type -> time__inst__padded_hour [color="#404040"];
	date__seq:year_minus_1980_type -> date__inst__year [color="#404040"];
	date__seq:day_type -> date__inst__padded_day [color="#404040"];
	date__seq:day_type -> date__inst__padded_day [color="#404040"];
	date__seq:month_type -> date__inst__padded_month [color="#404040"];
	date__seq:month_type -> date__inst__padded_month [color="#404040"];
	date__inst__year:year_type -> date__inst__padded_year [color="#404040"];
	date__inst__year:year_type -> date__inst__padded_year [color="#404040"];
	date__inst__year:year_type -> date__inst__padded_year [color="#404040"];
	date__inst__year:year_type -> date__inst__padded_year [color="#404040"];
}