26static char *DAYS[]={
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"};
28static char *FULLDAYS[]={
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
31static char *MONTHS[]={
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
32 "Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
34static char *FULLMONTHS[]={
"January",
"February",
"March",
"April",
"May",
"June",
35 "July",
"August",
"September",
"October",
"November",
"December"};
41static CritSec localtime_critsec;
43_CRTIMP
struct tm *localtime(
const time_t *clockval);
46static struct tm *localtime_r(
const time_t *clockval,
struct tm *res) {
48 localtime_critsec.
lock();
50 struct tm *static_tm = localtime(clockval);
51 res = (
struct tm *)memcpy(res, static_tm,
sizeof(tm));
53 localtime_critsec.
unlock();
86 struct _timeb wintime;
89 usec=(wintime.millitm)*1000;
92 struct timeval unixtime;
93 struct timezone unixtzone;
94 gettimeofday(&unixtime,&unixtzone);
96 usec=unixtime.tv_usec;
111 while ((!isgraph(*ptr))&&(*ptr!=0)) ptr++;
112 if (*ptr==0)
return(
FALSE);
115 if (strncmp(ptr,DAYS[i],strlen(DAYS[i]))==0)
119 while ((!isdigit(*ptr))&&(*ptr!=0)) ptr++;
120 if (*ptr==0)
return(
FALSE);
122 while ((!isalpha(*ptr))&&(*ptr!=0)) ptr++;
123 if (*ptr==0)
return(
FALSE);
126 if (strncmp(ptr,MONTHS[i],strlen(MONTHS[i]))==0) t.tm_mon=i;
127 if (t.tm_mon==-1)
return(
FALSE);
128 while ((!isdigit(*ptr))&&(*ptr!=0)) ptr++;
129 if (*ptr==0)
return(
FALSE);
133 else if (t.tm_year<100)
137 while ((isdigit(*ptr))&&(*ptr!=0)) ptr++;
138 if (*ptr==0)
return(
FALSE);
140 while ((!isgraph(*ptr))&&(*ptr!=0)) ptr++;
141 if (*ptr==0)
return(
FALSE);
144 while ((*ptr!=
':')&&(*ptr!=0)) ptr++;
146 if (*ptr==0)
return(
FALSE);
148 while ((*ptr!=
':')&&(*ptr!=0)) ptr++;
150 if (*ptr==0)
return(
FALSE);
163 while ((isdigit(*ptr))&&(*ptr!=0)) ptr++;
164 if (*ptr==0)
return(
TRUE);
167 while ((isspace(*ptr))&&(*ptr!=0)) ptr++;
201 if (*ptr==
'"') ptr++;
210 if (lastWasH==1) lastWasH=2;
211 sprintf(out+strlen(out),
"%c",*ptr);
214 else if (strncmp(ptr,
"\"",1)==0)
218 else if (strncmp(ptr,
":",1)==0)
220 if (lastWasH==1) lastWasH=2;
221 sprintf(out+strlen(out),
":");
224 else if (strncmp(ptr,
"/",1)==0)
226 sprintf(out+strlen(out),
"/");
229 else if (strncmp(ptr,
"c",1)==0)
231 sprintf(out+strlen(out),
"%ld/%ld/%02ld %ld:%02ld:%02ld",
GetMonth(),
235 else if (strncmp(ptr,
"dddddd",6)==0)
237 sprintf(out+strlen(out),
"%s %02ld, %ld",FULLMONTHS[
GetMonth()-1],
241 else if (strncmp(ptr,
"ddddd",5)==0)
247 else if (strncmp(ptr,
"dddd",4)==0)
249 sprintf(out+strlen(out),
"%s",FULLDAYS[
GetWDay()-1]);
252 else if (strncmp(ptr,
"ddd",3)==0)
254 sprintf(out+strlen(out),
"%s",DAYS[
GetWDay()-1]);
257 else if (strncmp(ptr,
"dd",2)==0)
259 sprintf(out+strlen(out),
"%02ld",
GetMDay());
262 else if (strncmp(ptr,
"d",1)==0)
264 sprintf(out+strlen(out),
"%ld",
GetMDay());
267 else if (strncmp(ptr,
"ww",2)==0)
269 sprintf(out+strlen(out),
"%02ld",
GetYWeek());
272 else if (strncmp(ptr,
"w",1)==0)
274 sprintf(out+strlen(out),
"%ld",
GetWDay());
277 else if (strncmp(ptr,
"mmmm",4)==0)
279 sprintf(out+strlen(out),
"%s",FULLMONTHS[
GetMonth()-1]);
282 else if (strncmp(ptr,
"mmm",3)==0)
284 sprintf(out+strlen(out),
"%s",MONTHS[
GetMonth()-1]);
287 else if (strncmp(ptr,
"mm",2)==0)
290 sprintf(out+strlen(out),
"%02ld",
GetMinute());
292 sprintf(out+strlen(out),
"%02ld",
GetMonth());
295 else if (strncmp(ptr,
"m",1)==0)
298 sprintf(out+strlen(out),
"%ld",
GetMinute());
300 sprintf(out+strlen(out),
"%ld",
GetMonth());
303 else if (strncmp(ptr,
"q",1)==0)
305 sprintf(out+strlen(out),
"%ld",((
GetMonth()-1)/4)+1);
308 else if (strncmp(ptr,
"yyyy",4)==0)
310 sprintf(out+strlen(out),
"%ld",
GetYear());
313 else if (strncmp(ptr,
"yy",2)==0)
315 sprintf(out+strlen(out),
"%02ld",
GetYear()%100);
318 else if (strncmp(ptr,
"y",1)==0)
320 sprintf(out+strlen(out),
"%ld",
GetYDay());
323 else if (strncmp(ptr,
"hh",2)==0)
325 sprintf(out+strlen(out),
"%02ld",
GetHour());
329 else if (strncmp(ptr,
"h",1)==0)
331 sprintf(out+strlen(out),
"%ld",
GetHour());
335 else if (strncmp(ptr,
"nn",2)==0)
337 sprintf(out+strlen(out),
"%02ld",
GetMinute());
340 else if (strncmp(ptr,
"n",1)==0)
342 sprintf(out+strlen(out),
"%ld",
GetMinute());
345 else if (strncmp(ptr,
"ss",2)==0)
347 sprintf(out+strlen(out),
"%02ld",
GetSecond());
350 else if (strncmp(ptr,
"s",1)==0)
352 sprintf(out+strlen(out),
"%ld",
GetSecond());
355 else if (strncmp(ptr,
"ttttt",5)==0)
361 else if (strncmp(ptr,
"aa",2)==0)
364 sprintf(out+strlen(out),
"%02ld", tmp);
379 sprintf(out+strlen(out),
"%s", ampm);
393 fprintf(out,
"%s",
string);
405 fprintf(out,
"%s",
string);
443 static struct timeval tv;
462 return(tptr->tm_sec);
469 return(tptr->tm_min);
476 return(tptr->tm_hour);
483 return(tptr->tm_mday);
490 return(tptr->tm_wday+1);
497 return(tptr->tm_yday+1);
505 sint32 phase=((wday-yday)%7);
506 if (phase<0) phase+=7;
507 yweek=((yday+phase-1)/7)+1;
515 return(tptr->tm_mon+1);
523 if ((tptr->tm_year)>=70)
524 return((tptr->tm_year)+1900);
526 return((tptr->tm_year)+2000);
593 if ((retval==-1)||(retval==0))
602 if ((retval==1)||(retval==0))
sint32 lock(int *refcount=NULL) RO
bit8 operator>=(const Wtime &other) const
int Compare(const Wtime &other) const
void SignedAdd(const Wtime &other)
void SignedSubtract(const Wtime &other)
struct timeval * GetTimeval(void)
bit8 operator<(const Wtime &other) const
void SetSec(uint32 newsec)
bit8 operator!=(const Wtime &other) const
uint32 GetSec(void) const
Wtime operator+(Wtime &other)
uint32 GetMinute(void) const
void SetUsec(uint32 newusec)
bit8 FormatTime(char *out, char *format)
bit8 operator<=(const Wtime &other) const
uint32 GetYDay(void) const
void PrintTime(FILE *out) const
uint32 GetWDay(void) const
uint32 GetMDay(void) const
uint32 GetMonth(void) const
void PrintDate(FILE *out) const
uint32 GetSecond(void) const
uint32 GetYear(void) const
Wtime & operator-=(const Wtime &other)
Wtime operator-(Wtime &other)
void Set(uint32 newsec, uint32 newusec)
void GetTimevalMT(struct timeval &tv)
uint32 GetHour(void) const
bit8 operator>(const Wtime &other) const
bit8 operator==(const Wtime &other) const
uint32 GetYWeek(void) const
Wtime & operator+=(const Wtime &other)
Wtime & operator=(const Wtime &other)
uint32 GetUsec(void) const