23 #include <sys/types.h> 35 #include <lib$routines.h> 65 rlTime::rlTime(
int Year,
int Month,
int Day,
int Hour,
int Minute,
int Second,
int Millisecond)
131 gettimeofday(&tv, &tz);
134 tms->tm_year += 1900;
138 second = (
int)tms->tm_sec;
139 minute = (int)tms->tm_min;
140 hour = (
int)tms->tm_hour;
141 day = (int)tms->tm_mday;
142 month = (
int)tms->tm_mon;
143 year = (int)tms->tm_year;
152 hour = (
int)tds.hour;
154 month = (
int)tds.month;
155 year = (int)tds.year;
177 if(lstat(filename,&statbuf))
return -1;
179 if(stat(filename,&statbuf))
return -1;
181 tms = localtime(&statbuf.st_mtime);
184 tms->tm_year += 1900;
188 second = (int)tms->tm_sec;
189 minute = (
int)tms->tm_min;
190 hour = (int)tms->tm_hour;
191 day = (
int)tms->tm_mday;
192 month = (int)tms->tm_mon;
193 year = (
int)tms->tm_year;
205 t.tm_mon =
month - 1;
206 t.tm_year =
year - 1900;
210 tv.tv_sec = mktime(&t);
212 settimeofday(&tv,NULL);
217 struct dsc$descriptor_s d_time;
218 char smonth[12][4],buf[64];
221 memset (smonth , 0,
sizeof(smonth));
222 memcpy (smonth [0],
"JAN", 3);
223 memcpy (smonth [1],
"FEB", 3);
224 memcpy (smonth [2],
"MAR", 3);
225 memcpy (smonth [3],
"APR", 3);
226 memcpy (smonth [4],
"MAY", 3);
227 memcpy (smonth [5],
"JUN", 3);
228 memcpy (smonth [6],
"JUL", 3);
229 memcpy (smonth [7],
"AUG", 3);
230 memcpy (smonth [8],
"SEP", 3);
231 memcpy (smonth [9],
"OCT", 3);
232 memcpy (smonth [10],
"NOV", 3);
233 memcpy (smonth [11],
"DEC", 3);
235 sprintf(buf,
"%02d-%3.3s-%04d %02d:%02d:%02d.%02d",
245 d_time.dsc$w_length = strlen(buf);
246 d_time.dsc$b_dtype = DSC$K_DTYPE_T;
247 d_time.dsc$b_class = DSC$K_CLASS_S;
248 d_time.dsc$a_pointer = buf;
250 sys$bintim(&d_time, &vbt);
314 int special = y % 400;
315 if(hth == 0 && special != 0) maxmonth = 28;
357 if(t.
day > maxmonth) { t.
month++; t.
day -= maxmonth; }
369 t.month =
month - time.month;
370 t.day =
day - time.day;
371 t.hour =
hour - time.hour;
372 t.minute =
minute - time.minute;
373 t.second =
second - time.second;
376 if(t.millisecond < 0) { t.second--; t.millisecond += 1000; }
377 if(t.second < 0) { t.minute--; t.second += 60; }
378 if(t.minute < 0) { t.hour--, t.minute += 60; }
379 if(t.hour < 0) { t.day--; t.hour += 24; }
386 if(m <= 0) { m += 12; y--; }
399 int special = y % 400;
400 if(hth == 0 && special != 0) maxmonth = 28;
447 { t.month++; t.day -= 30; }
448 if(t.day < 30) { t.day++; t.hour -= 24; }
449 if(t.hour < 0 ) { t.hour++; t.minute -= 60; }
450 if(t.minute < 0 ) { t.minute++; t.second -= 60; }
451 if(t.second < 0 ) { t.second++; t.millisecond -= 1000; }
459 if(
year != time.year)
return 0;
460 if(
month != time.month)
return 0;
461 if(
day != time.day)
return 0;
462 if(
hour != time.hour)
return 0;
463 if(
minute != time.minute)
return 0;
464 if(
second != time.second)
return 0;
485 if(diff.year < 0)
return 1;
486 if(diff.month < 0)
return 1;
487 if(diff.day < 0)
return 1;
488 if(diff.hour < 0)
return 1;
489 if(diff.minute < 0)
return 1;
490 if(diff.second < 0)
return 1;
491 if(diff.millisecond < 0)
return 1;
497 if((*
this) == time)
return 1;
498 if((*
this) < time)
return 1;
517 if(diff.year < 0)
return 1;
518 if(diff.month < 0)
return 1;
519 if(diff.day < 0)
return 1;
520 if(diff.hour < 0)
return 1;
521 if(diff.minute < 0)
return 1;
522 if(diff.second < 0)
return 1;
523 if(diff.millisecond < 0)
return 1;
529 if((*
this) == time)
return 1;
530 if((*
this) > time)
return 1;
539 memset(&begin,0,
sizeof(tm));
540 memset(&test,0,
sizeof(tm));
549 test.tm_year =
year - 1900;
550 test.tm_mon =
month - 1;
556 time_t t0 = mktime(&begin);
557 time_t t1 = mktime(&test);
559 return difftime(t1,t0) + (((double)
millisecond) / 1000);
int operator>(rlTime &time)
rlTime(int Year=0, int Month=0, int Day=0, int Hour=0, int Minute=0, int Second=0, int Millisecond=0)
const char * getIsoTimeString()
double secondsSinceEpoche()
rlTime operator-(rlTime &time)
int operator>=(rlTime &time)
rlTime & operator-=(rlTime &time)
void setTimeFromString(const char *time_string)
const char * getTimeString()
void setTimeFromIsoString(const char *iso_time_string)
int operator<(rlTime &time)
int operator==(rlTime &time)
int operator<=(rlTime &time)
rlTime operator+(rlTime &time)
int getFileModificationTime(const char *filename)
rlTime & operator+=(rlTime &time)