annotate src/vmstime.c @ 23965:8a2363657bcc

Fix typo.
author Markus Rost <rost@math.uni-bielefeld.de>
date Thu, 31 Dec 1998 01:49:11 +0000
parents 2bf083a9ad6a
children
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
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 4696
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 4696
diff changeset
19 Boston, MA 02111-1307, USA. */
2176
2c7e0875f6d0 Add GNU copyright notice.
Jim Blandy <jimb@redhat.com>
parents: 2174
diff changeset
20
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 2176
diff changeset
21 #include <config.h>
2174
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 #include "vmstime.h"
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 long timezone=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 int daylight=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 static char tzname_default[20]="";
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 static char tzname_dst[20]="";
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 char *tzname[2] = { tzname_default, tzname_dst };
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 static long internal_daylight=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 static char daylight_set=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 static long read_time(const char *nptr, const char **endptr,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 int sign_allowed_p)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 int t;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 *endptr = nptr;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 /* This routine trusts the user very much, and does no checks!
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 The only exception is this: */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 if (!sign_allowed_p && (*nptr == '-' || *nptr == '+'))
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 return 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 t = strtol(*endptr, endptr, 10) * 3600;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 if (**endptr != ':' || **endptr == '+' || **endptr == '-')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 return t;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 (*endptr)++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 t = t + strtol(*endptr, endptr, 10) * 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 if (**endptr != ':' || **endptr == '+' || **endptr == '-')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 return t;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (*endptr)++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 return t + strtol(*endptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 static void read_dst_time(const char *nptr, const char **endptr,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 int *m, int *n, int *d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 int *leap_p)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 time_t bintim = time(0);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 struct tm *lc = localtime(&bintim);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 *leap_p = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 *m = 0; /* When m and n are 0, a Julian */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 *n = 0; /* date has been inserted in d */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 switch(*nptr)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 case 'M':
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 /* This routine counts on the user to have specified "Mm.n.d",
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 where 1 <= n <= 5, 1 <= m <= 12, 0 <= d <= 6 */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 *m = strtol(++nptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 (*endptr)++; /* Skip the dot */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 *n = strtol(*endptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 (*endptr)++; /* Skip the dot */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 *d = strtol(*endptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 return;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 case 'J':
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 *leap_p = 0; /* Never count with leap years */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 default: /* trust the user to have inserted a number! */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 *d = strtol(++nptr, endptr, 10);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 return;
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
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 struct vms_vectim
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 short year, month, day, hour, minute, second, centi_second;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 };
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 static void find_dst_time(int m, int n, long d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 int hour, int minute, int second,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 int leap_p,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 long vms_internal_time[2])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 long status = SYS$GETTIM(vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 struct vms_vectim vms_vectime;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 status = SYS$NUMTIM(&vms_vectime, vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 if (m == 0 && n == 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 long tmp_vms_internal_time[2][2];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 long day_of_year;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 long tmp_operation = LIB$K_DAY_OF_YEAR;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 status = LIB$CVT_FROM_INTERNAL_TIME(&tmp_operation, &day_of_year,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 vms_vectime.month = 2;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 vms_vectime.day = 29;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 status = LIB$CVT_VECTIM(&vms_vectime, tmp_vms_internal_time[0]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 if (status & 1) /* This is a leap year */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 if (!leap_p && d > 59)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 d ++; /* If we don't count with 29th Feb,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 and this is a leap year, count up,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 to make day 60 really become the
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 1st March. */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 /* 1st January, at midnight */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 vms_vectime.month = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 vms_vectime.day = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 vms_vectime.hour = hour;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 vms_vectime.minute = minute;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 vms_vectime.second = second;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 vms_vectime.centi_second = 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 status = LIB$CVT_VECTIM(&vms_vectime, tmp_vms_internal_time[0]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 tmp_operation = LIB$K_DELTA_DAYS;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 status = LIB$CVT_TO_INTERNAL_TIME(&tmp_operation, &d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 tmp_vms_internal_time[1]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 /* now, tmp_vms_interval_time[0] contains 1st Jan, 00:00:00,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 and tmp_vms_interval_time[1] contains delta time +d days.
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 Let's just add them together */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 status = LIB$ADD_TIMES(tmp_vms_internal_time[0],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 tmp_vms_internal_time[1],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 long tmp_vms_internal_time[2];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 long day_of_week;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 long tmp_operation = LIB$K_DAY_OF_YEAR;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 if (d == 0) /* 0 is Sunday, which isn't compatible with VMS,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 where day_of_week is 1 -- 7, and 1 is Monday */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 d = 7; /* So a simple conversion is required */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 vms_vectime.month = m;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 vms_vectime.day = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 vms_vectime.hour = hour;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 vms_vectime.minute = minute;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 vms_vectime.second = second;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 vms_vectime.centi_second = 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 status = LIB$CVT_VECTIM(&vms_vectime, tmp_vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 tmp_operation = LIB$K_DAY_OF_WEEK;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 status = LIB$CVT_FROM_INTERNAL_TIME(&tmp_operation, &day_of_week,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 tmp_vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 d -= day_of_week;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 if (d < 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 d += 7;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 vms_vectime.day += (n-1)*7 + d;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 status = LIB$CVT_VECTIM(&vms_vectime, vms_internal_time);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 if (!(status & 1))
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 vms_vectime.day -= 7; /* n was probably 5 */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 status = LIB$CVT_VECTIM(&vms_vectime, vms_internal_time);
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
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 static cmp_vms_internal_times(long vms_internal_time1[2],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 long vms_internal_time2[2])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 if (vms_internal_time1[1] < vms_internal_time2[1])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 return -1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 if (vms_internal_time1[1] > vms_internal_time2[1])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 return 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 if (vms_internal_time1[0] < vms_internal_time2[0])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 return -1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 if (vms_internal_time1[0] > vms_internal_time2[0])
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 return 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 return 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 /* -------------------------- Global routines ------------------------------ */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 #ifdef tzset
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 #undef tzset
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 #endif
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 void sys_tzset()
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 char *TZ;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 char *p, *q;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 if (daylight_set)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 return;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 daylight = 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 if ((TZ = getenv("TZ")) == 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 return;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 p = TZ;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 q = tzname[0];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 while(*p != '\0'
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 && (*p <'0' || *p > '9') && *p != '-' && *p != '+' && *p != ',')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 *q++ = *p++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 *q = '\0';
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 /* 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
226 else */
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 timezone = read_time(p, &p, 1);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 q = tzname[1];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 while(*p != '\0'
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 && (*p <'0' || *p > '9') && *p != '-' && *p != '+' && *p != ',')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 *q++ = *p++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 *q = '\0';
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 if (*p != '-' && *p != '+' && !(*p >='0' && *p <= '9'))
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 internal_daylight = timezone - 3600;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 internal_daylight = read_time(p, &p, 1);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 if (*p == ',')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 int start_m;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 int start_n;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 int start_d;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 int start_leap_p;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 int start_hour=2, start_minute=0, start_second=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 p++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 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
252 if (*p == '/')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 long tmp = read_time (++p, &p, 0);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 start_hour = tmp / 3600;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 start_minute = (tmp % 3600) / 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 start_second = tmp % 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 if (*p == ',')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 int end_m;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 int end_n;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 int end_d;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 int end_leap_p;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 int end_hour=2, end_minute=0, end_second=0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 p++;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 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
269 if (*p == '/')
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 long tmp = read_time (++p, &p, 0);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 end_hour = tmp / 3600;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 end_minute = (tmp % 3600) / 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 end_second = tmp % 60;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 long vms_internal_time[3][2];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 find_dst_time(start_m, start_n, start_d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 start_hour, start_minute, start_second,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 start_leap_p,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 vms_internal_time[0]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 SYS$GETTIM(&vms_internal_time[1]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 find_dst_time(end_m, end_n, end_d,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 end_hour, end_minute, end_second,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 end_leap_p,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 if (cmp_vms_internal_times(vms_internal_time[0],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 vms_internal_time[1]) < 0
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 && cmp_vms_internal_times(vms_internal_time[1],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 vms_internal_time[2]) < 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 daylight = 1;
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
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 #ifdef localtime
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 #undef localtime
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 #endif
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 struct tm *sys_localtime(time_t *clock)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 struct tm *tmp = localtime(clock);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 sys_tzset();
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 tmp->tm_isdst = daylight;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 return tmp;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 #ifdef gmtime
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 #undef gmtime
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 #endif
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 struct tm *sys_gmtime(time_t *clock)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 static struct tm gmt;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 struct vms_vectim tmp_vectime;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 long vms_internal_time[3][2];
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 long tmp_operation = LIB$K_DELTA_SECONDS;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 long status;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 long tmp_offset;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 char tmp_o_sign;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 sys_tzset();
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 if (daylight)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 tmp_offset = internal_daylight;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 tmp_offset = timezone;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 if (tmp_offset < 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 tmp_o_sign = -1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 tmp_offset = -tmp_offset;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 tmp_o_sign = 1;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 status = LIB$CVT_TO_INTERNAL_TIME(&tmp_operation, &tmp_offset,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 vms_internal_time[1]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 status = SYS$GETTIM(vms_internal_time[0]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 if (tmp_o_sign < 0)
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 status = LIB$SUB_TIMES(vms_internal_time[0],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 vms_internal_time[1],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 else
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 {
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 status = LIB$ADD_TIMES(vms_internal_time[0],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 vms_internal_time[1],
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 status = SYS$NUMTIM(&tmp_vectime, vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 gmt.tm_sec = tmp_vectime.second;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 gmt.tm_min = tmp_vectime.minute;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 gmt.tm_hour = tmp_vectime.hour;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 gmt.tm_mday = tmp_vectime.day;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 gmt.tm_mon = tmp_vectime.month - 1;
15666
2bf083a9ad6a (sys_gmtime): Don't assume year < 2000.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
360 gmt.tm_year = tmp_vectime.year - 1900;
2174
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 tmp_operation = LIB$K_DAY_OF_WEEK;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 status = LIB$CVT_FROM_INTERNAL_TIME(&tmp_operation,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 &gmt.tm_wday,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 if (gmt.tm_wday == 7) gmt.tm_wday = 0;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 tmp_operation = LIB$K_DAY_OF_YEAR;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 status = LIB$CVT_FROM_INTERNAL_TIME(&tmp_operation,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 &gmt.tm_yday,
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 vms_internal_time[2]);
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 gmt.tm_yday--;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 gmt.tm_isdst = daylight;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 return &gmt;
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 }
19cda372de6e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377