Mapper
shlocl.c
Go to the documentation of this file.
1 /*Translated by FOR_C, v3.4.2 (-), on 04/06/95 at 13:56:10 */
2 /*FOR_C Options SET: c=4 com=u do=r44 ftn=ln6kk op=iv s=dvnk str=l sq=i */
3 #define _POSIX_SOURCE
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <ctype.h>
7 #include <dirent.h>
8 #include <unistd.h>
9 #include <math.h>
10 #include <string.h>
11 #include <fcntl.h>
12 #include <sys/stat.h>
13 #include "shef_structs_external.h"
14 
15 /*---------------------------------------------------------------------
16 
17  NAME
18  SUBROUTINE SHLOCL(NYEAR,NMON,NDAY,NHOUR,NMIN,NSEC,NADJTZ,IADJ,STATUS)
19 
20  PURPOSE
21 
22  This routine adjusts the time difference between the local time
23  and zulu time depending on whether or not daylight
24  savings is in effect.
25  If IADJ comes in as 1 then the time coming in is zulu.
26  If IADJ comes in as 0 then the time coming in is local time.
27 
28  Daylight/Standard Switch over Dates
29 
30  The switch over dates for daylight and standard time for the
31  years 1976 through 2020 are contained in the table ITABLE.
32  In 1987, the law went into effect that made the change over
33  on the first Sunday in April, and the last Sunday in October.
34  ITABLE(1,I) IS THE CHANGE OVER DATE IN APRIL TO DAYLIGHT TIME.
35  ITABLE(2,I) IS THE CHANGE OVER DATE IN OCTOBER TO STANDARD TIME.
36  The change occurs at 2AM.
37 
38  **** The TABLE is located in BLOCKDATA ****
39  Each pair of numbers is associated with a year, beginning
40  with 1976. The first number is the first Sunday in April
41  and the second number is the last Sunday in October.
42 
43  DATA ITABLE
44  > /26,31, 24,30, 30,29, 29,28, 27,26, 26,25,
45  > 25,31, 24,30, 29,28, 28,27, 27,26, 5,25,
46  > 3,30, 2,29, 1,28, 7,27, 5,25, 4,31,
47  > 3,30, 2,29, 7,27, 6,26, 5,25, 4,31,
48  > 2,29, 1,28, 7,27, 6,26, 4,31, 3,30,
49  > 2,29, 1,28, 6,26, 5,25, 4,31, 3,30,
50  > 1,28, 7,27, 6,26, 5,25, 3,30, 2,29,
51  > 1,28, 7,27, 5,25/
52 
53  VERSION and UPDATES
54  1.0 AUG 82 Geoffrey M. Bonnin
55  Original Version
56  1.1 AUG 84
57  Add seconds to time.
58  2.0 JUN 94 David G. Brandon
59  Daylight switchover date now good through year 2020
60  Also Translated to 'C' using FOR_C
61  Removed alternate returns to subroutines
62  2.1 Include check to test if years are valid between
63  1976 and 2020 (since these are the only years which
64  are included in the table). Include t_data struct
65  so that century is brought over.
66  2.2 OCT 19 97 DGB
67  Fix problem with associating dates in the array
68  datet_.itable[][] with the correct years and days.
69  Previously, the switchover days for daylight/standard
70  did not match up properly.
71  2.3 OCT 18 2012 RKH
72  Shift to Daylight in March and November since 2007.
73  -------------------------------------------------------------------- */
74 
75 
76 
77 void shlocl(nyear, nmon, nday, nhour, nmin, nsec, nadjtz, iadj, status)
78 short int *nyear, *nmon, *nday, *nhour, *nmin, *nsec, *nadjtz, *iadj,
79  *status;
80 {
81  static short int ia, ib, iy, num, ntemp;
82 int k,i;
83 
84  *status = 0;
85 
86  /* Test if adjustment necesary */
87 
88  if( *nadjtz >= 0 )
89  goto L_50;
90 
91 
92  /* check if the year is between 1976 and 2020 & if adjustment is */
93  /* necessary. */
94 
95  if ( *nyear < 1976 || *nyear > 2020 )
96  goto L_9010;
97 
98  /* Check whether the time is in local or zulu */
99  ia = 2;
100  ib = 2;
101  if( *iadj != 1 )
102  goto L_5;
103  ia = 2 - *nadjtz/60;
104  ib = 1 - *nadjtz/60;
105 
106  /* Adjust the year to suit the bounds of the ITABLE */
107 
108 L_5:
109  if( ( *nyear >= 1976) && ( *nyear <= 2020) )
110  iy = *nyear -1976; /* dgb:10/19/97 */
111  else
112  goto L_9010;
113 
114 
115  /* Test if daylight time */
116 
117 if(*nyear < 2007)
118 {
119  /* April & October time changes */
120  if( (*nmon < 4) || (*nmon > 10) )
121  goto L_40;
122  if( (*nmon > 4) && (*nmon < 10) )
123  goto L_20;
124  if( *nmon == 10 )
125  goto L_10;
126 
127  /* April */
128 
129  if( *nday < datet_.itable[iy][0] ) /* dgb:10/19/97 */
130  goto L_40;
131  if( *nday > datet_.itable[iy][0] ) /* dgb:10/19/97 */
132  goto L_20;
133 
134  if( *iadj == 1 )
135  goto L_8;
136  if( *nhour != 2 )
137  goto L_8;
138 /*
139  if( *nmin != 0 )
140  goto L_9020;
141  if( *nsec != 0 )
142  goto L_9020;
143 */
144 L_8:
145  if( *nhour < ia )
146  goto L_40;
147  if( *nhour > ia )
148  goto L_20;
149  if( *nmin > 0 )
150  goto L_20;
151  if( *nsec > 0 )
152  goto L_20;
153  goto L_40;
154 
155  /* October */
156 
157 L_10:
158  if( *nday > datet_.itable[iy][1] ) /* dgb:10/19/97 */
159  goto L_40;
160  if( *nday < datet_.itable[iy][1] ) /* dgb:10/19/97 */
161  goto L_20;
162  if( *nhour > ib )
163  goto L_40;
164  if( *nhour < ib )
165  goto L_20;
166  if( *nmin > 0 )
167  goto L_40;
168  if( *nsec > 0 )
169  goto L_40;
170 
171  /* Adjust for daylight time */
172 
173 L_20:
174  *iadj = -(*nadjtz + 60);
175  goto L_100;
176 
177  /* Standard time */
178 
179 L_40:
180  *iadj = -*nadjtz;
181  goto L_100;
182 
183  /* No adjustment necessary */
184 
185 L_50:
186  *iadj = *nadjtz;
187 
188 
189 L_100:
190  return;
191 
192  /* Error return */
193 
194 }
195 else
196 {
197  /* March & November time changes */
198 
199  if( (*nmon < 3) || (*nmon > 11) )
200  goto L_40x;
201  if( (*nmon > 3) && (*nmon < 11) )
202  goto L_20x;
203  if( *nmon == 11 )
204  goto L_10x;
205 
206  /* March */
207 
208  if( *nday < datet_.itable[iy][0] ) /* dgb:10/19/97 */
209  goto L_40x;
210  if( *nday > datet_.itable[iy][0] ) /* dgb:10/19/97 */
211  goto L_20x;
212 
213  if( *iadj == 1 )
214  goto L_8x;
215  if( *nhour != 2 )
216  goto L_8;
217 /*
218  if( *nmin != 0 )
219  goto L_9020;
220  if( *nsec != 0 )
221  goto L_9020;
222 */
223 L_8x:
224  if( *nhour < ia )
225  goto L_40x;
226  if( *nhour > ia )
227  goto L_20x;
228  if( *nmin > 0 )
229  goto L_20x;
230  if( *nsec > 0 )
231  goto L_20x;
232  goto L_40x;
233 
234  /* November */
235 
236 L_10x:
237  if( *nday > datet_.itable[iy][1] ) /* dgb:10/19/97 */
238  goto L_40x;
239  if( *nday < datet_.itable[iy][1] ) /* dgb:10/19/97 */
240  goto L_20x;
241  if( *nhour > ib )
242  goto L_40x;
243  if( *nhour < ib )
244  goto L_20x;
245  if( *nmin > 0 )
246  goto L_40x;
247  if( *nsec > 0 )
248  goto L_40x;
249 
250  /* Adjust for daylight time */
251 
252 L_20x:
253  *iadj = -(*nadjtz + 60);
254  goto L_100x;
255 
256  /* Standard time */
257 
258 L_40x:
259  *iadj = -*nadjtz;
260  goto L_100x;
261 
262  /* No adjustment necessary */
263 
264 L_50x:
265  *iadj = *nadjtz;
266 
267 
268 L_100x:
269  return;
270 }
271 
272 L_9010:
273  num = 22;
274  goto L_9500;
275 
276 /*
277 L_9020:
278  num = 37;
279 */
280 
281 L_9500:
282  sherr( &num );
283  *status = 1;
284  return;
285 
286 }
287 
static int i
int k
Definition: mapp2h.h:48
struct t_datet_ datet_
void sherr(short int *ier)
Definition: sherr.c:44
ib
Definition: shleap.cc:46
ia
Definition: shleap.cc:45
void shlocl(short int *nyear, short int *nmon, short int *nday, short int *nhour, short int *nmin, short int *nsec, short int *nadjtz, short int *iadj, short int *status)
Definition: shlocl.c:77
short int itable[45][2]
Definition: shef_structs.h:174