Changeset 664
- Timestamp:
- Sep 8, 2003, 9:56:28 PM (22 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 5 edited
-
include/emx/time.h (modified) (1 diff, 1 prop)
-
src/lib/sys/__ftime.c (modified) (2 diffs, 1 prop)
-
src/lib/time/ftime.c (modified) (1 diff, 1 prop)
-
src/lib/time/gettimeo.c (modified) (1 diff, 1 prop)
-
src/lib/time/tzset.c (modified) (7 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/emx/time.h
-
Property cvs2svn:cvs-rev
changed from
1.2to1.3
r663 r664 18 18 struct tm; 19 19 20 21 22 20 23 struct _tzinfo 21 24 { 22 char tzname[ 4];23 char dstzname[ 4];25 char tzname[]; 26 char dstzname[]; 24 27 int tz, dst, shift; 25 28 int sm, sw, sd, st; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__ftime.c
-
Property cvs2svn:cvs-rev
changed from
1.4to1.5
r663 r664 7 7 #include <emx/time.h> 8 8 #include <emx/syscalls.h> 9 9 10 #include "syscalls.h" 10 11 12 11 13 void __ftime (struct timeb *ptr) 12 14 { … … 21 23 tm.tm_mon = now.month - 1; 22 24 tm.tm_year = now.year - 1900; 23 tm.tm_isdst = -1; /* unknown */ 25 24 26 ptr->time = (time_t)_mktime (&tm); 27 28 29 30 31 25 32 ptr->millitm = now.hundredths * 10; 26 ptr->timezone = now.timezone;27 ptr->dstflag = 0;28 33 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/ftime.c
-
Property cvs2svn:cvs-rev
changed from
1.5to1.6
r663 r664 15 15 t_loc = ptr->time; 16 16 ptr->dstflag = _loc2gmt (&ptr->time, -1); 17 ptr->timezone = (int)(ptr->time - t_loc)/ 60;17 ptr->timezone = / 60; 18 18 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/gettimeo.c
-
Property cvs2svn:cvs-rev
changed from
1.5to1.6
r663 r664 25 25 if (tzp != NULL) 26 26 { 27 tzp->tz_minuteswest = (int)(tb.time - t_loc)/ 60;27 tzp->tz_minuteswest = / 60; 28 28 tzp->tz_dsttime = dst; 29 29 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/tzset.c
-
Property cvs2svn:cvs-rev
changed from
1.4to1.5
r663 r664 10 10 #include <emx/syscalls.h> 11 11 12 int _ daylight= 0;13 long _ timezone= 0;14 char *_ tzname[2] = {"GMT", ""};12 int _ = 0; 13 long _ = 0; 14 char *_[2] = {"GMT", ""}; 15 15 16 16 struct _tzinfo _tzi = {"GMT", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; … … 88 88 p = *pp; 89 89 90 /* Check the supposed timezone name for validity. See ISO 9945-1, 91 8.1.1 for details. */ 92 93 if (*p == ':' || (*p >= '0' && *p <= '9')) 94 return 0; 95 for (i = 0; i < 3; ++i) 96 if (p[i] == 0 || p[i] == ',' || p[i] == '-' || p[i] == '+') 97 return 0; 90 /* Check the supposed timezone name for validity. 91 See ISO 9945-1, 8.1.1 for details. */ 92 if (!(i = strcspn (p, ":,+-"))) 93 return 0; 98 94 99 95 /* The timezone name is valid. */ 100 101 memcpy (dst, p, 3); 102 dst[3] = 0; 103 *pp = p + 3; 104 return 1; 105 } 106 107 96 *pp = p + i; 97 if (i > __MAX_TZ_STANDARD_LEN) 98 i = __MAX_TZ_STANDARD_LEN; 99 memcpy (dst, p, i); 100 dst [i] = 0; 101 return 1; 102 } 103 104 static int parse_delta (char **src, int *offset, int opt_sign) 105 { 106 int ofs = 0, sign = 1, temp; 107 108 if (!dnum (&ofs, src, -23, 23, opt_sign, -1)) 109 return 0; 110 if (ofs < 0) 111 sign = -1, ofs = -ofs; 112 113 ofs *= 60; 114 if (**src == ':') /* Minutes specified? */ 115 { 116 (*src)++; 117 if (!dnum (&temp, src, 0, 59, 0, -1)) 118 return 0; 119 ofs += temp; 120 } 121 122 ofs *= 60; 123 if (**src == ':') /* Seconds specified? */ 124 { 125 (*src)++; 126 if (!dnum (&temp, src, 0, 59, 0, -1)) 127 return 0; 128 ofs += temp; 129 } 130 131 *offset = sign > 0 ? ofs : -ofs; 132 133 return 1; 134 } 135 136 static int parse_switchtime (char **src, int *m, int *w, int *d, int *t) 137 { 138 if (!dnum (m, src, 1, 12, 0, ',') 139 || !dnum (w, src, -4, 4, 1, ',') 140 || !dnum (d, src, *w ? 0 : 1, *w ? 6 : 31, 0, ',') 141 || !dnum (t, src, 0, 86399, 0, ',')) 142 return 0; 143 144 return 1; 145 } 146 147 /* The format of TZ environment variable: 148 * 149 * TZ1[OFF,[TZ2[,SM,SW,SD,ST,EM,EW,ED,ET,SHIFT]]] 150 * 151 * TZ1 is the at least three-letter name of the standard timezone. 152 * 153 * OFF is the offset to Coordinated Universal Time; positive values are to the 154 * west of the Prime Meridian, negative values are to the east of the Prime 155 * Meridian. The offset has the format [H[:M[:S]]]. 156 * 157 * TZ2 is the three-letter name of the summer timezone (daylight saving time). 158 * If TZ2 is not specified, daylight saving time does not apply. 159 * 160 * SM specifies the month (1 through 12) of the change. SW specifies the week 161 * of the change; if this value is zero, SD specifies the day of month 162 * (1 through 31). If SW is positive (1 through 4), the change occurs on 163 * weekday SD (0=Sunday through 6=Saturday) of the SWth week of the specified 164 * month. The first week of a month starts on the first Sunday of the month. 165 * If SW is negative (-1 through -4), the change occurs on weekday SD 166 * (0=Sunday through 6=Saturday) of the -SWth week of the specified month, 167 * counted from the end of the month (that is, -1 specifies the last week of 168 * the month). The last week of a month starts on the last Sunday of the 169 * month. ST specifies the time of the change, in seconds. Note that ST is 170 * specified in local standard time and ET is specified in local daylight 171 * saving time. 172 * 173 * Example: 174 * CET-1CED,3,-1,0,7200,10,-1,0,10800,3600 175 * KWT-4KWST,3,-1,0,7200,10,-1,0,10800,3600 176 */ 108 177 void _STD(tzset) (void) 109 178 { … … 111 180 struct timeb tb; 112 181 char *p; 113 int sign, offset, temp;182 int ; 114 183 time_t t_loc; 115 184 116 185 p = getenv ("TZ"); 117 if (p == NULL) 118 p = "GMT0"; /* Our best approximation :-) */ 119 if (*p == 0) 120 p = "GMT0"; 186 if (p == NULL || *p == 0) 187 p = "GMT"; /* Our best approximation :-) */ 121 188 122 189 if (!copy_tzname (ntz.tzname, &p)) … … 124 191 125 192 if (*p == 0) 126 offset = sign = 0; /* TZ=XYZ is valid (in contrast to POSIX.1) */ 127 else 128 { 129 if (!dnum (&offset, &p, -24, 24, 1, -1)) 130 return; 131 if (offset < 0) 132 sign = -1, offset = -offset; 133 else 134 sign = 1; 135 136 offset *= 60; 137 if (*p == ':') /* Minutes specified? */ 138 { 139 ++p; 140 if (!dnum (&temp, &p, 0, 59, 0, -1)) 141 return; 142 offset += temp; 143 } 144 145 offset *= 60; 146 if (*p == ':') /* Seconds specified? */ 147 { 148 ++p; 149 if (!dnum (&temp, &p, 0, 59, 0, -1)) 150 return; 151 offset += temp; 152 } 153 } 154 155 ntz.tz = sign > 0 ? offset : -offset; 193 offset = 0; /* TZ=XYZ is valid (in contrast to POSIX.1) */ 194 else if (!parse_delta (&p, &offset, 1)) 195 return; 196 197 ntz.tz = offset; 156 198 157 199 ntz.dst = 0; … … 162 204 ntz.dst = 1; 163 205 if (!copy_tzname (ntz.dstzname, &p)) 164 return ;206 return; 165 207 if (*p == ',') 166 208 { 167 ++p; 168 if (!dnum (&ntz.sm, &p, 1, 12, 0, ',') 169 || !dnum (&ntz.sw, &p, -4, 4, 1, ',') 170 || !dnum (&ntz.sd, &p, ntz.sw ? 0 : 1, ntz.sw ? 6 : 31, 0, ',') 171 || !dnum (&ntz.st, &p, 0, 86399, 0, ',') 172 || !dnum (&ntz.em, &p, 1, 12, 0, ',') 173 || !dnum (&ntz.ew, &p, -4, 4, 1, ',') 174 || !dnum (&ntz.ed, &p, ntz.ew ? 0 : 1, ntz.ew ? 6 : 31, 0, ',') 175 || !dnum (&ntz.et, &p, 0, 86399, 0, ',') 176 || !dnum (&ntz.shift, &p, 0, 86400, 0, 0)) 209 p++; 210 /* Parse DST start date/time */ 211 if (!parse_switchtime (&p, &ntz.sm, &ntz.sw, &ntz.sd, &ntz.st)) 212 return; 213 if (!parse_switchtime (&p, &ntz.em, &ntz.ew, &ntz.ed, &ntz.et)) 214 return; 215 if (!dnum (&ntz.shift, &p, 0, 86400, 0, 0)) 177 216 return; 178 217 } … … 180 219 { 181 220 /* VAC++ default values */ 182 183 221 ntz.sm = 4; ntz.sw = 1; ntz.sd = 0; ntz.st = 3600; 184 222 ntz.em = 10; ntz.ew = -1; ntz.ed = 0; ntz.et = 7200; … … 194 232 /* TODO: Make this thread-safe! */ 195 233 _tzi = ntz; 196 _ tzname[0] = _tzi.tzname;197 _ tzname[1] = _tzi.dstzname;234 _[0] = _tzi.tzname; 235 _[1] = _tzi.dstzname; 198 236 _compute_dst_table (); 199 237 200 238 __ftime (&tb); 201 239 t_loc = tb.time; 202 _ daylight= _loc2gmt (&tb.time, -1);203 _ timezone = (int)(tb.time - t_loc);240 _ = _loc2gmt (&tb.time, -1); 241 _; 204 242 205 243 _tzset_flag = 1; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
