22 #define CWB_MJD_REF 2400000.5 // Reference Julian Day for Mean Julian Day 47 setenv(
"TZ",
":UTC", 1);
49 if (
mNSec >= 1000000000 ) {
59 setenv(
"TZ",
":UTC", 1);
70 setenv(
"TZ",
":UTC", 1);
85 if (
this != &time ) {
102 if (
mNSec >= 1000000000 ) {
135 unsigned long long tmp = d*1000000000;
136 unsigned long long lsec1 = d;
137 unsigned long long lnsec1 = (tmp%1000000000)/100;
138 unsigned long long lsec2 =
mSec;
139 unsigned long long lnsec2 =
mNSec/100;
141 tmp = lsec1*lsec2*1000000000+(lsec1*lnsec2+lnsec1*lsec2)*100+(lnsec1*lnsec2)/100000;
143 mSec = tmp/1000000000;
144 mNSec = tmp%1000000000;
157 double ns =
mNSec / d;
191 return !( *
this > time );
200 return !( *
this < time );
209 return !( *
this == time );
314 unsigned long long tmp = dt*1000000000;
315 mNSec = (tmp%1000000000);
335 if (date.CompareTo(
"now")==0) {
336 time_t ticks = time(NULL);
337 this->
SetSec(mktime(gmtime(&ticks)));
346 if (date.IsDigit()) {this->
SetSec(date.Atoi());
return;}
349 if (date.Sizeof()==20) {
352 if (yy>=80)
if(xx!=19) {
354 sprintf(msg,
"error in data format : %s [Year >= 1980 && <2079]",date.Data());
357 if (yy<80)
if(xx!=20) {
359 sprintf(msg,
"error in data format : %s [Year >= 1980 && <2079]",date.Data());
362 idate = date(17,2)+
":"+date(14,2)+
":"+date(11,2)+
"-"+date(8,2)+
":"+date(5,2)+
":"+date(2,2);
366 SetString(const_cast<char*>(idate.Data()));
375 char DD_s[4],MM_s[4],YY_s[4],hh_s[4],mm_s[4],ss_s[4];
376 int DD,MM,YY,
hh,mm,
ss;
378 if (strlen(date) != 17)
Error(const_cast<char*>(
"date length not valid"));
380 strncpy(ss_s,date,2);
381 if(!isdigit(ss_s[0]))
Error(const_cast<char*>(
"sec not valid format"));
382 if(!isdigit(ss_s[1]))
Error(const_cast<char*>(
"sec not valid format"));
386 strncpy(mm_s,date+3,2);
387 if(!isdigit(mm_s[0]))
Error(const_cast<char*>(
"minutes not valid format"));
388 if(!isdigit(mm_s[1]))
Error(const_cast<char*>(
"minutes not valid format"));
392 strncpy(hh_s,date+6,2);
393 if(!isdigit(hh_s[0]))
Error(const_cast<char*>(
"hour not valid format"));
394 if(!isdigit(hh_s[1]))
Error(const_cast<char*>(
"hour not valid format"));
398 strncpy(DD_s,date+9,2);
399 if(!isdigit(DD_s[0]))
Error(const_cast<char*>(
"day not valid format"));
400 if(!isdigit(DD_s[1]))
Error(const_cast<char*>(
"day not valid format"));
404 strncpy(MM_s,date+12,2);
405 if(!isdigit(MM_s[0]))
Error(const_cast<char*>(
"month not valid format"));
406 if(!isdigit(MM_s[1]))
Error(const_cast<char*>(
"month not valid format"));
410 strncpy(YY_s,date+15,2);
411 if(!isdigit(YY_s[0]))
Error(const_cast<char*>(
"year not valid format"));
412 if(!isdigit(YY_s[1]))
Error(const_cast<char*>(
"year not valid format"));
417 SetDate(ss,mm,hh,DD,MM,YY,nsec);
424 if(YY>1900) YY-=1900;
438 setenv(
"TZ",
":UTC", 1);
440 time_t in_utc_sec = mktime(&in_tp);
441 struct tm* out_tp = gmtime(&in_utc_sec);
442 time_t out_utc_sec = mktime(out_tp);
446 if (in_tp.tm_sec != ss)
Error(const_cast<char*>(
"sec not valid format"));
447 if (in_tp.tm_min != mm)
Error(const_cast<char*>(
"minutes not valid format"));
448 if (in_tp.tm_hour != hh)
Error(const_cast<char*>(
"hour not valid format"));
449 if (in_tp.tm_mday != DD)
Error(const_cast<char*>(
"day not valid format"));
450 if (in_tp.tm_mon != MM-1)
Error(const_cast<char*>(
"month not valid format"));
451 if (in_tp.tm_year != YY)
Error(const_cast<char*>(
"year not valid format"));
453 if(in_utc_sec != out_utc_sec)
Error(const_cast<char*>(
"Date not valid format"));
463 Time tempTime(*
this);
465 time_t time = tempTime.
GetSec();
478 TObjString* week_tok = (TObjString*)token->At(0);
479 TString week = week_tok->GetString();
480 TObjString* month_tok = (TObjString*)token->At(1);
481 TString month = month_tok->GetString();
482 TObjString* day_tok = (TObjString*)token->At(2);
483 TString day = day_tok->GetString();
484 TObjString* hhmmss_tok = (TObjString*)token->At(3);
485 TString hhmmss = hhmmss_tok->GetString();
486 if(leap) {hhmmss[6]=
'6';hhmmss[7]=
'0';}
487 TObjString* year_tok = (TObjString*)token->At(4);
488 TString year = year_tok->GetString();
489 year.Resize(year.Sizeof()-2);
491 if(month.CompareTo(
"Jan")==0) month=
"01";
492 if(month.CompareTo(
"Feb")==0) month=
"02";
493 if(month.CompareTo(
"Mar")==0) month=
"03";
494 if(month.CompareTo(
"Apr")==0) month=
"04";
495 if(month.CompareTo(
"May")==0) month=
"05";
496 if(month.CompareTo(
"Jun")==0) month=
"06";
497 if(month.CompareTo(
"Jul")==0) month=
"07";
498 if(month.CompareTo(
"Aug")==0) month=
"08";
499 if(month.CompareTo(
"Sep")==0) month=
"09";
500 if(month.CompareTo(
"Oct")==0) month=
"10";
501 if(month.CompareTo(
"Nov")==0) month=
"11";
502 if(month.CompareTo(
"Dec")==0) month=
"12";
506 sprintf(date,
"%s-%s-%02d %s UTC %s",year.Data(),month.Data(),day.Atoi(),hhmmss.Data(),week.Data());
573 const int sec_per_day = 60 * 60 * 24;
574 int year, month, day, sec;
578 if(
GetYear()<=0)
Error(const_cast<char*>(
"Year must be after 1900"));
585 jd = 367*year - 7*(year + (month + 9)/12)/4 + 275*month/9 + day + 1721014;
587 jd += (double)sec/(
double)sec_per_day - 0.5;
605 if(TMath::IsNaN(jd))
Error(const_cast<char*>(
"julian day is a NaN"));
634 out << time.
GetSec() <<
":";
wavearray< double > t(hp.size())
Time & operator=(Time &time)
void SetDate(int ss, int mm, int hh, int DD, int MM, int YY, int nsec=0)
bool operator!=(Time &time)
void SetDateString(TString date)
Time operator-(Time &t1, Time &t2)
void SetString(char *date, int nsec=0)
Time operator+(Time &t1, Time &t2)
Time operator*(Time &t, double &d)
INT_4U SetNSec(INT_4U nsec)
cout<< "Selected Pixels : "<< nPix<< endl;wc.cluster(1, 1);SSeries< double > ss
istream & operator>>(istream &in, Time &time)
double operator/(Time &time)
#define GPS_LEAPS_TABLE_SIZE
ostream & operator<<(ostream &out, Time &time)
void SetDouble(double dt)
bool operator==(Time &time)
static const gps_leap gps_leaps_table[GPS_LEAPS_TABLE_SIZE]
bool operator<=(Time &time)
Time operator/(Time &t, double &d)
Time & operator*=(double &d)
Time(INT_4S sec=0, INT_4U nsec=0)
double GetModJulianDate()
Time & operator-=(Time &time)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
Time & operator+=(Time &time)
bool operator<(Time &time)
Time & operator/=(double &d)
bool operator>=(Time &time)
bool operator>(Time &time)