This source file includes following definitions.
- isonum_711
- isonum_712
- isonum_721
- isonum_722
- isonum_723
- isonum_731
- isonum_732
- isonum_733
- iso_date
1
2
3
4
5
6
7
8
9
10
11
12
13 int
14 isonum_711 (p)
15 char *p;
16 {
17 return (*p & 0xff);
18 }
19
20 int
21 isonum_712 (p)
22 char *p;
23 {
24 int val;
25
26 val = *p;
27 if (val & 0x80)
28 val |= 0xffffff00;
29 return (val);
30 }
31
32 int
33 isonum_721 (p)
34 char *p;
35 {
36 return ((p[0] & 0xff) | ((p[1] & 0xff) << 8));
37 }
38
39 int
40 isonum_722 (p)
41 char *p;
42 {
43 return (((p[0] & 0xff) << 8) | (p[1] & 0xff));
44 }
45
46 int
47 isonum_723 (p)
48 char *p;
49 {
50 #if 0
51 if (p[0] != p[3] || p[1] != p[2]) {
52 fprintf (stderr, "invalid format 7.2.3 number\n");
53 exit (1);
54 }
55 #endif
56 return (isonum_721 (p));
57 }
58
59 int
60 isonum_731 (p)
61 char *p;
62 {
63 return ((p[0] & 0xff)
64 | ((p[1] & 0xff) << 8)
65 | ((p[2] & 0xff) << 16)
66 | ((p[3] & 0xff) << 24));
67 }
68
69 int
70 isonum_732 (p)
71 char *p;
72 {
73 return (((p[0] & 0xff) << 24)
74 | ((p[1] & 0xff) << 16)
75 | ((p[2] & 0xff) << 8)
76 | (p[3] & 0xff));
77 }
78
79 int
80 isonum_733 (p)
81 char *p;
82 {
83 #if 0
84 int i;
85
86 for (i = 0; i < 4; i++) {
87 if (p[i] != p[7-i]) {
88 fprintf (stderr, "bad format 7.3.3 number\n");
89 exit (1);
90 }
91 }
92 #endif
93 return (isonum_731 (p));
94 }
95
96 int iso_date(p, flag)
97 char * p;
98 int flag;
99 {
100 int year, month, day, hour ,minute, second, tz;
101 int crtime, days, i;
102
103 year = p[0] - 70;
104 month = p[1];
105 day = p[2];
106 hour = p[3];
107 minute = p[4];
108 second = p[5];
109 if (flag == 0) tz = p[6];
110 else tz = 0;
111
112 if (year < 0) {
113 crtime = 0;
114 } else {
115 int monlen[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
116 days = year * 365;
117 if (year > 2)
118 days += (year+2) / 4;
119 for (i = 1; i < month; i++)
120 days += monlen[i-1];
121 if (((year+2) % 4) == 0 && month > 2)
122 days++;
123 days += day - 1;
124 crtime = ((((days * 24) + hour) * 60 + minute) * 60)
125 + second;
126
127
128 if (tz & 0x80)
129 tz |= (-1 << 8);
130
131
132 if (-48 <= tz && tz <= 52)
133 crtime += tz * 15 * 60;
134 }
135 return crtime;
136 }
137