1 // SPDX-License-Identifier: GPL-2.0
3 * linux/fs/isofs/util.c
6 #include <linux/time.h>
10 * We have to convert from a MM/DD/YY format to the Unix ctime format.
11 * We have to take into account leap years and all of that good stuff.
12 * Unfortunately, the kernel does not have the information on hand to
13 * take into account daylight savings time, but it shouldn't matter.
14 * The time stored should be localtime (with or without DST in effect),
15 * and the timezone offset should hold the offset required to get back
16 * to GMT. Thus we should always be correct.
19 int iso_date(u8
*p
, int flag
)
21 int year
, month
, day
, hour
, minute
, second
, tz
;
30 if (flag
== 0) tz
= p
[6]; /* High sierra has no time zone */
36 crtime
= mktime64(year
+1900, month
, day
, hour
, minute
, second
);
43 * The timezone offset is unreliable on some disks,
44 * so we make a sanity check. In no case is it ever
45 * more than 13 hours from GMT, which is 52*15min.
46 * The time is always stored in localtime with the
47 * timezone offset being what get added to GMT to
48 * get to localtime. Thus we need to subtract the offset
49 * to get to true GMT, which is what we store the time
50 * as internally. On the local system, the user may set
51 * their timezone any way they wish, of course, so GMT
52 * gets converted back to localtime on the receiving
55 * NOTE: mkisofs in versions prior to mkisofs-1.10 had
56 * the sign wrong on the timezone offset. This has now
57 * been corrected there too, but if you are getting screwy
58 * results this may be the explanation. If enough people
59 * complain, a user configuration option could be added
60 * to add the timezone offset in with the wrong sign
61 * for 'compatibility' with older discs, but I cannot see how
62 * it will matter that much.
64 * Thanks to kuhlmav@elec.canterbury.ac.nz (Volker Kuhlmann)
65 * for pointing out the sign error.
67 if (-52 <= tz
&& tz
<= 52)
68 crtime
-= tz
* 15 * 60;