Lines Matching +full:binary +full:- +full:coded

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2006 Poul-Henning Kamp
7 * Redistribution and use in source and binary forms, with or without
12 * 2. Redistributions in binary form must reproduce the above copyright
28 * Convert MS-DOS FAT format timestamps to and from unix timespecs
33 * yyyyyyymmmmddddd (year - 1980, month, day)
54 * The conversion functions below cut time into four-year leap-year
64 * they can represent up to 2107 which means that the non-leap-year
80 #define LYC (4 * YEAR + 1) /* Length of 4 year leap-year cycle */
98 /* Table of months in a 4 year leap-year cycle */
104 uint16_t coded; /* encoded year + month information */
144 t1 = tsp->tv_sec;
146 t1 -= utc_offset();
149 *dhp = (tsp->tv_sec & 1) * 100 + tsp->tv_nsec / 10000000;
158 /* Impossible date, truncate to 1980-01-01 */
161 t2 -= T1980;
164 if (t2 >= ((2100 - 1980) / 4 * LYC + FEB))
170 t2 -= l * LYC;
180 *ddp += mtab[m].coded;
183 t2 -= mtab[m].days - 1;
192 * leap-year cycle
222 tsp->tv_sec = (dt & 0x1f) << 1;
223 tsp->tv_sec += ((dt & 0x7e0) >> 5) * 60;
224 tsp->tv_sec += ((dt & 0xf800) >> 11) * 3600;
225 tsp->tv_sec += dh / 100;
226 tsp->tv_nsec = (dh % 100) * 10000000;
229 day = (dd & 0x1f) - 1;
231 /* Full leap-year cycles */
234 /* Month offset from leap-year cycle */
238 if (day >= ((2100 - 1980) / 4 * LYC + FEB))
239 day--;
244 tsp->tv_sec += (time_t) DAY * day;
246 tsp->tv_sec += utc_offset();
269 * 32-bits gets us to 2106-02-07 06:28:15, but we
271 * a 36-bit second count to get us way past 2106.
278 printf("%10jd.%03ld -- ", (intmax_t) ts.tv_sec, ts.tv_nsec / 1000000);
282 printf("%s -- ", buf);
284 a = ts.tv_sec + ts.tv_nsec * 1e-9;
287 printf("%04x %04x %02x -- ", d, t, p);
288 printf("%3d %02d %02d %02d %02d %02d -- ",
301 printf("%s -- ", buf);
302 a -= ts.tv_sec + ts.tv_nsec * 1e-9;