23 #include <sys/types.h> 35 #include <lib$routines.h> 62 rlTime::rlTime(
int Year,
int Month,
int Day,
int Hour,
int Minute,
int Second,
int Millisecond)
163 while(*format !=
'\0')
165 if (strncmp(format,
"dd",2) == 0)
167 sprintf(buf,
"%02d",
day);
172 else if(strncmp(format,
"d",1) == 0)
174 sprintf(buf,
"%d",
day);
179 else if(strncmp(format,
"MMM",3) == 0)
182 if(
month == 1) strcpy(buf,
"Jan");
183 if(
month == 2) strcpy(buf,
"Feb");
184 if(
month == 3) strcpy(buf,
"Mar");
185 if(
month == 4) strcpy(buf,
"Apr");
186 if(
month == 5) strcpy(buf,
"May");
187 if(
month == 6) strcpy(buf,
"Jun");
188 if(
month == 7) strcpy(buf,
"Jul");
189 if(
month == 8) strcpy(buf,
"Aug");
190 if(
month == 9) strcpy(buf,
"Sep");
191 if(
month == 10) strcpy(buf,
"Oct");
192 if(
month == 11) strcpy(buf,
"Nov");
193 if(
month == 12) strcpy(buf,
"Dec");
198 else if(strncmp(format,
"MM",2) == 0)
200 sprintf(buf,
"%02d",
month);
205 else if(strncmp(format,
"M",1) == 0)
207 sprintf(buf,
"%d",
month);
212 else if(strncmp(format,
"yyyy",4) == 0)
214 sprintf(buf,
"%4d",
year);
219 else if(strncmp(format,
"yy",2) == 0)
221 sprintf(buf,
"%4d",
year);
222 strcpy(dest,&buf[2]);
223 dest += strlen(&buf[2]);
226 else if(strncmp(format,
"hh",2) == 0)
228 if (
hour > 12) sprintf(buf,
"%02d",
hour - 12);
229 else if(
hour == 0) sprintf(buf,
"%02d", 12);
230 else sprintf(buf,
"%02d",
hour);
235 else if(strncmp(format,
"h",1) == 0)
237 if (
hour > 12) sprintf(buf,
"%2d",
hour - 12);
238 else if(
hour == 0) sprintf(buf,
"%2d", 12);
239 else sprintf(buf,
"%2d",
hour);
244 else if(strncmp(format,
"HH",2) == 0)
246 sprintf(buf,
"%02d",
hour);
251 else if(strncmp(format,
"H",1) == 0)
253 sprintf(buf,
"%d",
hour);
258 else if(strncmp(format,
"mm",2) == 0)
260 sprintf(buf,
"%02d",
minute);
265 else if(strncmp(format,
"m",1) == 0)
272 else if(strncmp(format,
"ss",2) == 0)
274 sprintf(buf,
"%02d",
second);
279 else if(strncmp(format,
"s",1) == 0)
286 else if(strncmp(format,
"zzz",3) == 0)
293 else if(strncmp(format,
"z",1) == 0)
300 else if(strncmp(format,
"AP",2) == 0)
302 if (
hour == 0) strcpy(dest,
"PM");
303 else if(
hour < 13) strcpy(dest,
"AM");
304 else strcpy(dest,
"PM");
305 dest += strlen(
"AM");
308 else if(strncmp(format,
"ap",2) == 0)
310 if (
hour == 0) strcpy(dest,
"pm");
311 else if(
hour < 13) strcpy(dest,
"am");
312 else strcpy(dest,
"pm");
313 dest += strlen(
"am");
316 else if(strncmp(format,
"A",1) == 0)
318 if (
hour == 0) strcpy(dest,
"PM");
319 else if(
hour < 13) strcpy(dest,
"AM");
320 else strcpy(dest,
"PM");
321 dest += strlen(
"AM");
324 else if(strncmp(format,
"a",1) == 0)
326 if (
hour == 0) strcpy(dest,
"pm");
327 else if(
hour < 13) strcpy(dest,
"am");
328 else strcpy(dest,
"pm");
329 dest += strlen(
"am");
352 gettimeofday(&tv, &tz);
355 tms->tm_year += 1900;
359 second = (
int)tms->tm_sec;
360 minute = (int)tms->tm_min;
361 hour = (
int)tms->tm_hour;
362 day = (int)tms->tm_mday;
363 month = (
int)tms->tm_mon;
364 year = (int)tms->tm_year;
373 hour = (
int)tds.hour;
375 month = (
int)tds.month;
376 year = (int)tds.year;
398 if(lstat(filename,&statbuf))
return -1;
400 if(stat(filename,&statbuf))
return -1;
402 tms = localtime(&statbuf.st_mtime);
405 tms->tm_year += 1900;
409 second = (int)tms->tm_sec;
410 minute = (
int)tms->tm_min;
411 hour = (int)tms->tm_hour;
412 day = (
int)tms->tm_mday;
413 month = (int)tms->tm_mon;
414 year = (
int)tms->tm_year;
426 t.tm_mon =
month - 1;
427 t.tm_year =
year - 1900;
431 tv.tv_sec = mktime(&t);
433 settimeofday(&tv,NULL);
438 struct dsc$descriptor_s d_time;
439 char smonth[12][4],buf[64];
442 memset (smonth , 0,
sizeof(smonth));
443 memcpy (smonth [0],
"JAN", 3);
444 memcpy (smonth [1],
"FEB", 3);
445 memcpy (smonth [2],
"MAR", 3);
446 memcpy (smonth [3],
"APR", 3);
447 memcpy (smonth [4],
"MAY", 3);
448 memcpy (smonth [5],
"JUN", 3);
449 memcpy (smonth [6],
"JUL", 3);
450 memcpy (smonth [7],
"AUG", 3);
451 memcpy (smonth [8],
"SEP", 3);
452 memcpy (smonth [9],
"OCT", 3);
453 memcpy (smonth [10],
"NOV", 3);
454 memcpy (smonth [11],
"DEC", 3);
456 sprintf(buf,
"%02d-%3.3s-%04d %02d:%02d:%02d.%02d",
466 d_time.dsc$w_length = strlen(buf);
467 d_time.dsc$b_dtype = DSC$K_DTYPE_T;
468 d_time.dsc$b_class = DSC$K_CLASS_S;
469 d_time.dsc$a_pointer = buf;
471 sys$bintim(&d_time, &vbt);
535 int special = y % 400;
536 if(hth == 0 && special != 0) maxmonth = 28;
578 if(t.
day > maxmonth) { t.
month++; t.
day -= maxmonth; }
607 if(m <= 0) { m += 12; y--; }
620 int special = y % 400;
621 if(hth == 0 && special != 0) maxmonth = 28;
684 if(
day != time.
day)
return 0;
708 if(diff.
year < 0)
return 1;
709 if(diff.
month < 0)
return 1;
710 if(diff.
day < 0)
return 1;
711 if(diff.
hour < 0)
return 1;
712 if(diff.
minute < 0)
return 1;
713 if(diff.
second < 0)
return 1;
720 if((*
this) == time)
return 1;
721 if((*
this) < time)
return 1;
740 if(diff.
year < 0)
return 1;
741 if(diff.
month < 0)
return 1;
742 if(diff.
day < 0)
return 1;
743 if(diff.
hour < 0)
return 1;
744 if(diff.
minute < 0)
return 1;
745 if(diff.
second < 0)
return 1;
752 if((*
this) == time)
return 1;
753 if((*
this) > time)
return 1;
762 memset(&begin,0,
sizeof(tm));
763 memset(&test,0,
sizeof(tm));
774 test.tm_year =
year - 1900;
775 test.tm_mon =
month - 1;
781 time_t t0 = mktime(&begin);
782 time_t t1 = mktime(&test);
784 return difftime(t1,t0) + (((double)
millisecond) / 1000);
const char * getTimeString()
int operator>=(rlTime &time)
rlTime & operator-=(rlTime &time)
const char * toString(const char *format)
void setTimeFromIsoString(const char *iso_time_string)
const char * getIsoTimeString()
int operator==(rlTime &time)
int operator<=(rlTime &time)
rlTime operator-(rlTime &time)
rlTime & operator+=(rlTime &time)
rlTime operator+(rlTime &time)
int getFileModificationTime(const char *filename)
double secondsSinceEpoche()
rlTime(int Year=0, int Month=0, int Day=0, int Hour=0, int Minute=0, int Second=0, int Millisecond=0)
int operator>(rlTime &time)
void setTimeFromString(const char *time_string)
int operator<(rlTime &time)