Mapper
shleap.c
Go to the documentation of this file.
1 /*Translated by FOR_C, v3.4.2 (-), on 06/07/94 at 17:02:47 */
2 /*FOR_C Options SET: c=2 com=u do=r4 ftn=2ln6k op=iv s=dvn 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  NAME
17  SUBROUTINE SHLEAP(LYEAR,LEAP)
18 
19  PURPOSE
20  Determine if the year is a leap year or not.
21 
22  Returns:
23  LEAP = 0 , not a leap year
24  LEAP = 1 , leap year
25 
26  LYAER = 2 digit year, e.g., 1999 = 99, 2010 = 10
27 
28  VERSION and UPDATES
29  1.0 APR 82 Geoffrey M. Bonnin
30  Original Version
31  1.1 JUN 89 David G. Brandon
32  Adapted to QNX NWS Hydromet
33  2.0 MAY 94 David G. Brandon
34  Also Translated to 'C' using FOR_C
35  Alow to check years: 1976 - 2020
36  2.1 JAN 4 2000 DGB
37  Allow year to be either 2 or 4 digits.
38  If 2 digits, get century from system.
39  If 4 digits, use CCYY as given.
40  --------------------------------------------------------------------- */
41 
42 void shleap(lyear, leap)
43 short int *lyear, *leap;
44 {
45  static short int ia, ib, ic;
46  static char tempb[5];
47 
48  sprintf(tempb,"%d",*lyear); /* dgb:01/04/00 */
49  if ( strlen(tempb) > 2 ) /* dgb:01/04/00 */
50  {
51  *leap = *lyear;
52  } /* dgb:01/04/00 */
53  else /* dgb:01/04/00 */
54  *leap = data_.lcent*100 + *lyear;
55 
56  ia = (*leap - (*leap/4)*4 + 3)/4;
57  ib = (*leap - (*leap/100)*100 + 99)/100;
58  ic = (*leap - (*leap/400)*400 + 399)/400;
59 
60  *leap = 1 - ia + ib - ic; /* LEAP IS 1 IF LEAP YEAR */
61 
62  return;
63 
64 }
65 
66 
67 
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
unsigned int ic
Definition: mapp2h.h:47
struct t_data_ data_
void shleap(short int *lyear, short int *leap)
Definition: shleap.c:42
ib
Definition: shleap.cc:46
void * leap
Definition: shleap.cc:39
ia
Definition: shleap.cc:45
short int lcent
Definition: shef_structs.h:177