annotate src/vmstime.c @ 2243:23228edebc59

Fix spacing conventions.
author Richard M. Stallman <rms@gnu.org>
date Thu, 18 Mar 1993 10:18:30 +0000
parents 2c7e0875f6d0
children 1fc792473491
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2176
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
1 /* Time support for VMS.
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
2 Copyright (C) 1993 Free Software Foundation.
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
3
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
4 This file is part of GNU Emacs.
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
5
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
7 it under the terms of the GNU General Public License as published by
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
9 any later version.
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
10
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
14 GNU General Public License for more details.
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
15
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
16 You should have received a copy of the GNU General Public License
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
19
2174
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 #include "config.h"
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 #include "vmstime.h"
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 long timezone=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 int daylight=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 static char tzname_default[20]="";
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 static char tzname_dst[20]="";
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 char *tzname[2] = { tzname_default, tzname_dst };
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 static long internal_daylight=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 static char daylight_set=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 static long read_time(const char *nptr, const char **endptr,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 int sign_allowed_p)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 int t;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 *endptr = nptr;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 /* This routine trusts the user very much, and does no checks!
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 The only exception is this: */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 if (!sign_allowed_p && (*nptr == '-' || *nptr == '+'))
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 return 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 t = strtol(*endptr, endptr, 10) * 3600;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 if (**endptr != ':' || **endptr == '+' || **endptr == '-')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 return t;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 (*endptr)++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 t = t + strtol(*endptr, endptr, 10) * 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 if (**endptr != ':' || **endptr == '+' || **endptr == '-')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 return t;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (*endptr)++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 return t + strtol(*endptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 static void read_dst_time(const char *nptr, const char **endptr,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 int *m, int *n, int *d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 int *leap_p)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 time_t bintim = time(0);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 struct tm *lc = localtime(&bintim);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 *leap_p = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 *m = 0; /* When m and n are 0, a Julian */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 *n = 0; /* date has been inserted in d */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 switch(*nptr)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 case 'M':
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 /* This routine counts on the user to have specified "Mm.n.d",
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 where 1 <= n <= 5, 1 <= m <= 12, 0 <= d <= 6 */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 *m = strtol(++nptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 (*endptr)++; /* Skip the dot */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 *n = strtol(*endptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (*endptr)++; /* Skip the dot */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 *d = strtol(*endptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 return;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 case 'J':
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 *leap_p = 0; /* Never count with leap years */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 default: /* trust the user to have inserted a number! */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 *d = strtol(++nptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 return;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 struct vms_vectim
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 short year, month, day, hour, minute, second, centi_second;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 };
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 static void find_dst_time(int m, int n, long d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 int hour, int minute, int second,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 int leap_p,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 long vms_internal_time[2])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 long status = SYS$GETTIM(vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 struct vms_vectim vms_vectime;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 status = SYS$NUMTIM(&vms_vectime, vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 if (m == 0 && n == 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 long tmp_vms_internal_time[2][2];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 long day_of_year;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 long tmp_operation = LIB$K_DAY_OF_YEAR;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 status = LIB$CVT_FROM_INTERNAL_TIME(&tmp_operation, &day_of_year,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 vms_vectime.month = 2;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 vms_vectime.day = 29;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 status = LIB$CVT_VECTIM(&vms_vectime, tmp_vms_internal_time[0]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 if (status & 1) /* This is a leap year */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 if (!leap_p && d > 59)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 d ++; /* If we don't count with 29th Feb,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 and this is a leap year, count up,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 to make day 60 really become the
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 1st March. */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 /* 1st January, at midnight */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 vms_vectime.month = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 vms_vectime.day = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 vms_vectime.hour = hour;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 vms_vectime.minute = minute;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 vms_vectime.second = second;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 vms_vectime.centi_second = 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 status = LIB$CVT_VECTIM(&vms_vectime, tmp_vms_internal_time[0]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 tmp_operation = LIB$K_DELTA_DAYS;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 status = LIB$CVT_TO_INTERNAL_TIME(&tmp_operation, &d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 tmp_vms_internal_time[1]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 /* now, tmp_vms_interval_time[0] contains 1st Jan, 00:00:00,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 and tmp_vms_interval_time[1] contains delta time +d days.
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 Let's just add them together */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 status = LIB$ADD_TIMES(tmp_vms_internal_time[0],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 tmp_vms_internal_time[1],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 long tmp_vms_internal_time[2];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 long day_of_week;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 long tmp_operation = LIB$K_DAY_OF_YEAR;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 if (d == 0) /* 0 is Sunday, which isn't compatible with VMS,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 where day_of_week is 1 -- 7, and 1 is Monday */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 d = 7; /* So a simple conversion is required */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 vms_vectime.month = m;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 vms_vectime.day = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 vms_vectime.hour = hour;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 vms_vectime.minute = minute;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 vms_vectime.second = second;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 vms_vectime.centi_second = 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 status = LIB$CVT_VECTIM(&vms_vectime, tmp_vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 tmp_operation = LIB$K_DAY_OF_WEEK;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 status = LIB$CVT_FROM_INTERNAL_TIME(&tmp_operation, &day_of_week,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 tmp_vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 d -= day_of_week;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 if (d < 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 d += 7;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 vms_vectime.day += (n-1)*7 + d;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 status = LIB$CVT_VECTIM(&vms_vectime, vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 if (!(status & 1))
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 vms_vectime.day -= 7; /* n was probably 5 */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 status = LIB$CVT_VECTIM(&vms_vectime, vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 static cmp_vms_internal_times(long vms_internal_time1[2],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 long vms_internal_time2[2])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 if (vms_internal_time1[1] < vms_internal_time2[1])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 return -1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 if (vms_internal_time1[1] > vms_internal_time2[1])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 return 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 if (vms_internal_time1[0] < vms_internal_time2[0])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 return -1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 if (vms_internal_time1[0] > vms_internal_time2[0])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 return 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 return 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 /* -------------------------- Global routines ------------------------------ */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 #ifdef tzset
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 #undef tzset
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 #endif
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 void sys_tzset()
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 char *TZ;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 char *p, *q;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 if (daylight_set)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 return;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 daylight = 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 if ((TZ = getenv("TZ")) == 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 return;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 p = TZ;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 q = tzname[0];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 while(*p != '\0'
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 && (*p <'0' || *p > '9') && *p != '-' && *p != '+' && *p != ',')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 *q++ = *p++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 *q = '\0';
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 /* This is special for VMS, so I don't care if it doesn't exist anywhere
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 else */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 timezone = read_time(p, &p, 1);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 q = tzname[1];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 while(*p != '\0'
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 && (*p <'0' || *p > '9') && *p != '-' && *p != '+' && *p != ',')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 *q++ = *p++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 *q = '\0';
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 if (*p != '-' && *p != '+' && !(*p >='0' && *p <= '9'))
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 internal_daylight = timezone - 3600;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 internal_daylight = read_time(p, &p, 1);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 if (*p == ',')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 int start_m;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 int start_n;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 int start_d;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 int start_leap_p;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 int start_hour=2, start_minute=0, start_second=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 p++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 read_dst_time(p, &p, &start_m, &start_n, &start_d, &start_leap_p);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 if (*p == '/')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 long tmp = read_time (++p, &p, 0);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 start_hour = tmp / 3600;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 start_minute = (tmp % 3600) / 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 start_second = tmp % 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 if (*p == ',')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 int end_m;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 int end_n;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 int end_d;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 int end_leap_p;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 int end_hour=2, end_minute=0, end_second=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 p++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 read_dst_time(p, &p, &end_m, &end_n, &end_d, &end_leap_p);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 if (*p == '/')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 long tmp = read_time (++p, &p, 0);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 end_hour = tmp / 3600;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 end_minute = (tmp % 3600) / 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 end_second = tmp % 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 long vms_internal_time[3][2];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 find_dst_time(start_m, start_n, start_d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 start_hour, start_minute, start_second,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 start_leap_p,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 vms_internal_time[0]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 SYS$GETTIM(&vms_internal_time[1]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 find_dst_time(end_m, end_n, end_d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 end_hour, end_minute, end_second,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 end_leap_p,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 if (cmp_vms_internal_times(vms_internal_time[0],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 vms_internal_time[1]) < 0
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 && cmp_vms_internal_times(vms_internal_time[1],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 vms_internal_time[2]) < 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 daylight = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 #ifdef localtime
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 #undef localtime
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 #endif
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 struct tm *sys_localtime(time_t *clock)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 struct tm *tmp = localtime(clock);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 sys_tzset();
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 tmp->tm_isdst = daylight;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 return tmp;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 #ifdef gmtime
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 #undef gmtime
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 #endif
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 struct tm *sys_gmtime(time_t *clock)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 static struct tm gmt;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 struct vms_vectim tmp_vectime;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 long vms_internal_time[3][2];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 long tmp_operation = LIB$K_DELTA_SECONDS;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 long status;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 long tmp_offset;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 char tmp_o_sign;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 sys_tzset();
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 if (daylight)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 tmp_offset = internal_daylight;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 tmp_offset = timezone;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 if (tmp_offset < 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 tmp_o_sign = -1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 tmp_offset = -tmp_offset;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 tmp_o_sign = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 status = LIB$CVT_TO_INTERNAL_TIME(&tmp_operation, &tmp_offset,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 vms_internal_time[1]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 status = SYS$GETTIM(vms_internal_time[0]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 if (tmp_o_sign < 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 status = LIB$SUB_TIMES(vms_internal_time[0],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 vms_internal_time[1],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 status = LIB$ADD_TIMES(vms_internal_time[0],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 vms_internal_time[1],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 status = SYS$NUMTIM(&tmp_vectime, vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 gmt.tm_sec = tmp_vectime.second;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 gmt.tm_min = tmp_vectime.minute;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 gmt.tm_hour = tmp_vectime.hour;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 gmt.tm_mday = tmp_vectime.day;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 gmt.tm_mon = tmp_vectime.month - 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 gmt.tm_year = tmp_vectime.year % 100;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 tmp_operation = LIB$K_DAY_OF_WEEK;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 status = LIB$CVT_FROM_INTERNAL_TIME(&tmp_operation,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 &gmt.tm_wday,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 if (gmt.tm_wday == 7) gmt.tm_wday = 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 tmp_operation = LIB$K_DAY_OF_YEAR;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 status = LIB$CVT_FROM_INTERNAL_TIME(&tmp_operation,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 &gmt.tm_yday,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 gmt.tm_yday--;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 gmt.tm_isdst = daylight;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 return &gmt;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376