forked from larsbrinkhoff/pdp10-its-disassembler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdec.c
29 lines (26 loc) · 716 Bytes
/
dec.c
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
#include <string.h>
#include "dis.h"
/* Convert a DEC timestamp to year, month, day. */
static void
dec_date (word_t timestamp, int *year, int *month, int *day)
{
*day = timestamp % 31;
*month = (timestamp / 31) % 12;
*year = (timestamp / 31 / 12) + 1964;
}
/* Print DEC timestamp. */
void
print_dec_timestamp (FILE *f, word_t timestamp)
{
int year, month, day;
dec_date (timestamp, &year, &month, &day);
fprintf (f, "%4d-%02d-%02d", year, month + 1, day + 1);
}
/* Convert a DEC timesamp date to a struct tm. */
void
timestamp_from_dec (struct tm *tm, word_t timestamp)
{
memset (tm, 0, sizeof (struct tm));
dec_date (timestamp, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
tm->tm_year -= 1900;
}