XINU
date.h
Go to the documentation of this file.
1 /* date.h - ntim2xtim, xtim2ntim, isleap, utim2ltim */
2 
3 /************************************************************************/
4 /* */
5 /* Constants and declarations for date storage and conversion */
6 /* */
7 /* Xinu stores time as seconds past Jan 1, 1970 (UNIX format), with */
8 /* 1 being 1 second into Jan. 1, 1970, GMT (universal time). The */
9 /* Internet uses seconds past Jan 1, 1900 (also GMT or Universal Time) */
10 /* */
11 /************************************************************************/
12 
13 /* Conversion between network and local representations */
14 
15 #define ntim2xtim(x) ((x)-2208988800U) /* net-to-xinu time */
16 #define xtim2ntim(x) ((x)+2208988800U) /* xinu-to-net time */
17 
18 /* Constants for Daylight Savings Time */
19 
20 #define DATE_DST_OFF 0 /* force DST to be off */
21 #define DATE_DST_ON 1 /* force DST to be on */
22 #define DATE_DST_AUTO 2 /* compute DST automatically */
23 
24 /* Days in months and month names used to format a date */
25 
26 struct dateinfo {
27  uint32 dt_boot; /* time when system booted */
28  /* add clktime to get the */
29  /* current time-of-day */
30  bool8 dt_bootvalid; /* is dt_boot field valid? */
31  int32 dt_daylight; /* whether to compute daylight */
32  /* savings time */
33  int32 dt_msize[12]; /* days per month */
34  char *dt_mnam[12]; /* month names */
35  char *dt_dnam[7]; /* day names */
36 };
37 
38 extern struct dateinfo Date; /* Global date information */
39 
40 /* Constants for converting time to month/day/year/hour/minute/second */
41 
42 #define isleap(x) ((x)%4==0) /* leap year? (1970-2099) */
43 #define SECPERDY (60*60*24) /* one day in seconds */
44 #define SECPERHR (60*60) /* one hour in seconds */
45 #define SECPERMN (60) /* one minute in seconds */
46 
47 /* The local time zone can be set to EST, CST, MST,or PST. */
48 
49 #define ZONE_EST 5 /* Eastern Standard time is 5 */
50 #define ZONE_CST 6 /* hours west of England */
51 #define ZONE_MST 7
52 #define ZONE_PST 8
53 #define TIMEZONE ZONE_EST /* timezone for this system */
54 
55 /* In-line procedures to convert universal-to-local time and vice versa */
56 
57 #define utim2ltim(x) ((x)-TIMEZONE*SECPERHR)
58 #define ltim2utim(x) ((x)+TIMEZONE*SECPERHR)
59 
60 #define TIMERPORT 123 /* UDP port for time server */
61 #define TIMELPORT 53678 /* local UDP port for time */
62 
63 #ifndef TIMESERVER
64 #define TIMESERVER "128.10.19.24" /* IP address of NTP time server*/
65 #endif
66 
67 #define TIMETIMEOUT 2000 /* timeout for time server (ms) */
bool8 dt_bootvalid
Definition: date.h:30
Definition: date.h:26
int32 dt_msize[12]
Definition: date.h:33
byte bool8
Boolean値
Definition: kernel.h:36
char * dt_mnam[12]
Definition: date.h:34
char * dt_dnam[7]
Definition: date.h:35
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
struct dateinfo Date
Definition: ascdate.c:6
uint32 dt_boot
Definition: date.h:27
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
int32 dt_daylight
Definition: date.h:31