10 const double Timestamp::julian1970 = 2440587.5;
11 const int Timestamp::secPerDay = (24*60*60);
12 const double Timestamp::inverseNano = 1000 * 1000 * 1000;
13 const int Timestamp::inverseNanoInt = 1000 * 1000 * 1000;
14 const long int Timestamp::maxInt = 0x7fffffff;
16 Timestamp::TZOffset Timestamp::s_tz;
29 : m_time((time_t) seconds), m_nano(nano)
31 if ((nano >= inverseNanoInt) || (nano < 0) || (seconds < 0))
32 throw BadTimeInput(
"facilities::Timestamp bad nano argument");
39 secs = (julian - julian1970) * secPerDay;
41 if ((fabs(secs) > maxInt) || (secs < 0) )
42 throw BadTimeInput(
"Julian time not in range [1970, 2037]");
61 int minute,
int second,
62 int nano) : m_nano(nano) {
68 if ((month < 1 ) || (month > 12) || (day < 1) || (day > 31) ||
69 (hour < 0) || (hour > 23) ||
70 (minute < 0) || (minute > 59) ||
71 (second < 0 ) || (second >= 60) ||
72 (year < 1970) || (year > 2037) ||
73 (nano < 0 ) || (nano >= inverseNanoInt) )
74 throw BadTimeInput(
"facilities::Timestamp Bad subfield");
76 fields.tm_year = year - 1900;
77 fields.tm_mon = month - 1;
79 fields.tm_hour = hour;
80 fields.tm_min = minute;
81 fields.tm_sec = (
long int) second;
89 m_time = mktime(&fields) - Timestamp::s_tz.m_tzseconds;
100 double julian = (
m_time +
m_nano/inverseNano)/secPerDay;
101 julian += julian1970;
106 time_t Timestamp::toBinary(
const std::string& strTime) {
111 unsigned int oldPos = 0;
117 pos = strTime.find(delim, oldPos);
120 if (pos >= strTime.size())
return 0;
122 fields.tm_year = atoi((strTime.substr(oldPos, pos)).c_str()) - 1900;
123 if ((fields.tm_year < 70) || (fields.tm_year > 137))
126 pos = strTime.find(delim, oldPos);
129 if (pos >= strTime.size())
130 throw BadTimeInput(
"Bad string format for facilities::Timestamp");
132 fields.tm_mon = atoi((strTime.substr(oldPos, pos)).c_str()) - 1;
133 if ((fields.tm_mon < 0) || (fields.tm_mon > 11))
141 pos = strTime.find(delim, oldPos);
143 fields.tm_mday = atoi((strTime.substr(oldPos, pos)).c_str());
145 if ((fields.tm_mday < 1) || (fields.tm_mday > 31))
146 throw BadTimeInput(
"facilities::Timestamp bad day of month");
149 fields.tm_hour = fields.tm_min = fields.tm_sec = 0;
151 if (pos < strTime.size() ) {
155 pos = strTime.find(delim, oldPos);
157 fields.tm_hour = atoi((strTime.substr(oldPos, pos)).c_str());
158 if ((fields.tm_hour > 23) || (fields.tm_hour < 0))
162 if (pos < strTime.size() ) {
164 pos = strTime.find(delim, oldPos);
165 fields.tm_min = atoi((strTime.substr(oldPos, pos)).c_str());
166 if ((fields.tm_min > 59) || (fields.tm_hour < 0))
167 throw BadTimeInput(
"facilities::Timestamp bad minutes");
169 if (pos < strTime.size() ) {
171 pos = strTime.find(delim, oldPos);
172 fields.tm_sec = atoi((strTime.substr(oldPos, pos)).c_str());
173 if ((fields.tm_sec > 59) || (fields.tm_hour < 0))
174 throw BadTimeInput(
"facilities::Timestamp bad seconds");
182 return mktime(&fields) - Timestamp::s_tz.m_tzseconds;
185 void Timestamp::toString(time_t
bin, std::string& strTime) {
186 struct tm * fields = gmtime(&
bin);
191 char* bufPtr = &buf[0];
192 sprintf(buf,
"%i", fields->tm_year + 1900);
193 strTime += bufPtr; strTime +=
"-";
194 sprintf(buf,
"%02i", fields->tm_mon +1);
195 strTime += bufPtr; strTime +=
"-";
196 sprintf(buf,
"%02i", fields->tm_mday);
197 strTime += bufPtr; strTime +=
" ";
198 sprintf(buf,
"%02i", fields->tm_hour);
199 strTime += bufPtr; strTime +=
":";
200 sprintf(buf,
"%02i", fields->tm_min);
201 strTime += bufPtr; strTime +=
":";
202 sprintf(buf,
"%02i", fields->tm_sec);
207 Timestamp::TZOffset::TZOffset() {
219 m_tzseconds = mktime(&fields) - 12*60*60;
220 m_isDst = fields.tm_isdst;
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
std::string getString() const
Return string representation of time, not including nanoseconds;.
double getJulian() const
Return julian date.
int m_nano
Save fractional seconds separately (associated with m_time)
time_t m_time
internal binary rep of time; count seconds from Jan 1, 1970