SNAP Library 2.4, User Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tm.cpp
Go to the documentation of this file.
1 // Time-Names
3 bool TTmInfo::InitP=false;
8 
10  // english
11  UsMonthNmV.Add("jan"); UsMonthNmV.Add("feb"); UsMonthNmV.Add("mar");
12  UsMonthNmV.Add("apr"); UsMonthNmV.Add("may"); UsMonthNmV.Add("jun");
13  UsMonthNmV.Add("jul"); UsMonthNmV.Add("aug"); UsMonthNmV.Add("sep");
14  UsMonthNmV.Add("oct"); UsMonthNmV.Add("nov"); UsMonthNmV.Add("dec");
15  IAssert(UsMonthNmV.Len()==12);
16  // slovene
17  SiMonthNmV.Add("jan"); SiMonthNmV.Add("feb"); SiMonthNmV.Add("mar");
18  SiMonthNmV.Add("apr"); SiMonthNmV.Add("maj"); SiMonthNmV.Add("jun");
19  SiMonthNmV.Add("jul"); SiMonthNmV.Add("avg"); SiMonthNmV.Add("sep");
20  SiMonthNmV.Add("okt"); SiMonthNmV.Add("nov"); SiMonthNmV.Add("dec");
21  IAssert(SiMonthNmV.Len()==12);
22 }
23 
25  // english
26  UsDayOfWeekNmV.Add("sun"); UsDayOfWeekNmV.Add("mon");
27  UsDayOfWeekNmV.Add("tue"); UsDayOfWeekNmV.Add("wed");
28  UsDayOfWeekNmV.Add("thu"); UsDayOfWeekNmV.Add("fri");
29  UsDayOfWeekNmV.Add("sat");
31  // slovene
32  SiDayOfWeekNmV.Add("ned"); SiDayOfWeekNmV.Add("pon");
33  SiDayOfWeekNmV.Add("tor"); SiDayOfWeekNmV.Add("sre");
34  SiDayOfWeekNmV.Add("cet"); SiDayOfWeekNmV.Add("pet");
35  SiDayOfWeekNmV.Add("sob");
37 }
38 
39 int TTmInfo::GetMonthN(const TStr& MonthNm, const TLoc& Loc){
40  EnsureInit();
41  int MonthN=-1;
42  switch (Loc){
43  case lUs: MonthN=UsMonthNmV.SearchForw(MonthNm.GetLc()); break;
44  case lSi: MonthN=SiMonthNmV.SearchForw(MonthNm.GetLc()); break;
45  default: Fail;
46  }
47  if (MonthN==-1){return -1;} else {return MonthN+1;}
48 }
49 
50 TStr TTmInfo::GetMonthNm(const int& MonthN, const TLoc& Loc){
51  EnsureInit();
52  IAssert((1<=MonthN)&&(MonthN<=12));
53  switch (Loc){
54  case lUs: return UsMonthNmV[MonthN-1];
55  case lSi: return SiMonthNmV[MonthN-1];
56  default: Fail; return TStr();
57  }
58 }
59 
60 int TTmInfo::GetDayOfWeekN(const TStr& DayOfWeekNm, const TLoc& Loc){
61  EnsureInit();
62  int DayOfWeekN=-1;
63  switch (Loc){
64  case lUs: DayOfWeekN=UsDayOfWeekNmV.SearchForw(DayOfWeekNm.GetLc()); break;
65  case lSi: DayOfWeekN=SiDayOfWeekNmV.SearchForw(DayOfWeekNm.GetLc()); break;
66  default: Fail;
67  }
68  if (DayOfWeekN==-1){return -1;} else {return DayOfWeekN+1;}
69 }
70 
71 TStr TTmInfo::GetDayOfWeekNm(const int& DayOfWeekN, const TLoc& Loc){
72  EnsureInit();
73  IAssert((1<=DayOfWeekN)&&(DayOfWeekN<=7));
74  switch (Loc){
75  case lUs: return UsDayOfWeekNmV[DayOfWeekN-1];
76  case lSi: return SiDayOfWeekNmV[DayOfWeekN-1];
77  default: Fail; return TStr();
78  }
79 }
80 
81 TStr TTmInfo::GetHmFromMins(const int& Mins){
82  return TInt::GetStr(Mins/60, "%02d")+":"+TInt::GetStr(Mins%60, "%02d");
83 }
84 
85 int TTmInfo::GetTmUnitSecs(const TTmUnit& TmUnit) {
86  switch(TmUnit) {
87  case tmuYear : return 365*24*3600;
88  case tmuMonth : return 31*24*3600;
89  case tmuWeek : return 7*24*3600;
90  case tmuDay : return 24*3600;
91  case tmu12Hour : return 12*3600;
92  case tmu6Hour : return 6*3600;
93  case tmu4Hour : return 4*3600;
94  case tmu2Hour : return 2*3600;
95  case tmu1Hour : return 1*3600;
96  case tmu30Min : return 30*60;
97  case tmu15Min : return 15*60;
98  case tmu10Min : return 10*60;
99  case tmu1Min : return 60;
100  case tmu1Sec : return 1;
101  case tmuNodes : Fail;
102  case tmuEdges : Fail;
103  default: Fail;
104  }
105  return -1;
106 }
107 
109  switch(TmUnit) {
110  case tmuYear : return "Year";
111  case tmuMonth : return "Month";
112  case tmuWeek : return "Week";
113  case tmuDay : return "Day";
114  case tmu12Hour : return "12 Hours";
115  case tmu6Hour : return "6 Hours";
116  case tmu4Hour : return "4 Hours";
117  case tmu2Hour : return "2 Hours";
118  case tmu1Hour : return "1 Hour";
119  case tmu30Min : return "30 Minutes";
120  case tmu15Min : return "15 Minutes";
121  case tmu10Min : return "10 Minutes";
122  case tmu1Min : return "Minute";
123  case tmu1Sec : return "Second";
124  case tmuNodes : return "Nodes";
125  case tmuEdges : return "Edges";
126  default: Fail;
127  }
128  return TStr::GetNullStr();
129 }
130 
132  if (TmZoneStr=="A"){/* Alpha Time Zone Military*/ return "+1000";}
133  if (TmZoneStr=="ACDT"){/* Australian Central Daylight Time Australia */ return "+1030";}
134  if (TmZoneStr=="ACST"){/* Australian Central Standard Time Australia */ return "+0930";}
135  if (TmZoneStr=="ADT"){/* Atlantic Daylight Time North America */ return "-0300";}
136  if (TmZoneStr=="AEDT"){/* Australian Eastern Daylight Time or Australian Eastern Summer Time Australia */ return "+1100";}
137  if (TmZoneStr=="AEST"){/* Australian Eastern Standard Time Australia */ return "+1000";}
138  if (TmZoneStr=="AKDT"){/* Alaska Daylight Time North America */ return "-0800";}
139  if (TmZoneStr=="AKST"){/* Alaska Standard Time North America */ return "-0900";}
140  if (TmZoneStr=="AST"){/* Atlantic Standard Time North America */ return "-0400";}
141  if (TmZoneStr=="AWDT"){/* Australian Western Daylight Time Australia */ return "+0900";}
142  if (TmZoneStr=="AWST"){/* Australian Western Standard Time Australia */ return "+0800";}
143  if (TmZoneStr=="B"){/* Bravo Time Zone Military */ return "+0200";}
144  if (TmZoneStr=="BST"){/* British Summer Time Europe */ return "+0100";}
145  if (TmZoneStr=="C"){/* Charlie Time Zone Military */ return "+0300";}
146  if (TmZoneStr=="CDT"){/* Central Daylight Time North America */ return "-0500";}
147  if (TmZoneStr=="CDT"){/* Central Daylight Time Australia */ return "+1030";}
148  if (TmZoneStr=="CEDT"){/* Central European Daylight Time Europe */ return "+0200";}
149  if (TmZoneStr=="CEST"){/* Central European Summer Time Europe */ return "+0200";}
150  if (TmZoneStr=="CET"){/* Central European Time Europe */ return "+0100";}
151  if (TmZoneStr=="CST"){/* Central Standard Time North America */ return "-0600";}
152  if (TmZoneStr=="CST"){/* Central Summer Time Australia */ return "+1030";}
153  if (TmZoneStr=="CST"){/* Central Standard Time Australia */ return "+0930";}
154  if (TmZoneStr=="CXT"){/* Christmas Island Time Australia */ return "+0700";}
155  if (TmZoneStr=="D"){/* Delta Time Zone Military */ return "+0400";}
156  if (TmZoneStr=="E"){/* Echo Time Zone Military */ return "+0500";}
157  if (TmZoneStr=="EDT"){/* Eastern Daylight Time North America */ return "-0400";}
158  if (TmZoneStr=="EDT"){/* Eastern Daylight Time Australia */ return "+1100";}
159  if (TmZoneStr=="EEDT"){/* Eastern European Daylight Time Europe */ return "+0300";}
160  if (TmZoneStr=="EEST"){/* Eastern European Summer Time Europe */ return "+0300";}
161  if (TmZoneStr=="EET"){/* Eastern European Time Europe */ return "+0200";}
162  if (TmZoneStr=="EST"){/* Eastern Standard Time North America */ return "-0500";}
163  if (TmZoneStr=="EST"){/* Eastern Summer Time Australia */ return "+1100";}
164  if (TmZoneStr=="EST"){/* Eastern Standard Time Australia */ return "+1000";}
165  if (TmZoneStr=="F"){/* Foxtrot Time Zone Military */ return "+0600";}
166  if (TmZoneStr=="G"){/* Golf Time Zone Military */ return "+0700";}
167  if (TmZoneStr=="GMT"){/* Greenwich Mean Time Europe */ return "+0000";}
168  if (TmZoneStr=="H"){/* Hotel Time Zone Military */ return "+0800";}
169  if (TmZoneStr=="HAA"){/* Heure Avancee de l'Atlantique North America */ return "-0300";}
170  if (TmZoneStr=="HAC"){/* Heure Avancee du Centre North America */ return "-0500";}
171  if (TmZoneStr=="HADT"){/* Hawaii-Aleutian Daylight Time North America */ return "-0900";}
172  if (TmZoneStr=="HAE"){/* Heure Avancee de l'Est North America */ return "-0400";}
173  if (TmZoneStr=="HAP"){/* Heure Avancee du Pacifique North America */ return "-0700";}
174  if (TmZoneStr=="HAR"){/* Heure Avancee des Rocheuses North America */ return "-0600";}
175  if (TmZoneStr=="HAST"){/* Hawaii-Aleutian Standard Time North America */ return "-1000";}
176  if (TmZoneStr=="HAT"){/* Heure Avancee de Terre-Neuve North America */ return "-0230";}
177  if (TmZoneStr=="HAY"){/* Heure Avancee du Yukon North America */ return "-0800";}
178  if (TmZoneStr=="HNA"){/* Heure Normale de l'Atlantique North America */ return "-0400";}
179  if (TmZoneStr=="HNC"){/* Heure Normale du Centre North America */ return "-0600";}
180  if (TmZoneStr=="HNE"){/* Heure Normale de l'Est North America */ return "-0500";}
181  if (TmZoneStr=="HNP"){/* Heure Normale du Pacifique North America */ return "-0800";}
182  if (TmZoneStr=="HNR"){/* Heure Normale des Rocheuses North America */ return "-0700";}
183  if (TmZoneStr=="HNT"){/* Heure Normale de Terre-Neuve North America */ return "-0330";}
184  if (TmZoneStr=="HNY"){/* Heure Normale du Yukon North America */ return "-0900";}
185  if (TmZoneStr=="I"){/* India Time Zone Military */ return "+0900";}
186  if (TmZoneStr=="IST"){/* Irish Summer Time Europe */ return "+0100";}
187  if (TmZoneStr=="K"){/* Kilo Time Zone Military */ return "+1000";}
188  if (TmZoneStr=="L"){/* Lima Time Zone Military */ return "+1100";}
189  if (TmZoneStr=="M"){/* Mike Time Zone Military */ return "+1200";}
190  if (TmZoneStr=="MDT"){/* Mountain Daylight Time North America */ return "-0600";}
191  if (TmZoneStr=="MESZ"){/* Mitteleuropeische Sommerzeit Europe */ return "+0200";}
192  if (TmZoneStr=="MEZ"){/* Mitteleuropeische Zeit Europe */ return "+0100";}
193  if (TmZoneStr=="MSD"){/* Moscow Daylight Time Europe */ return "+0400";}
194  if (TmZoneStr=="MSK"){/* Moscow Standard Time Europe */ return "+0300";}
195  if (TmZoneStr=="MST"){/* Mountain Standard Time North America */ return "-0700";}
196  if (TmZoneStr=="N"){/* November Time Zone Military */ return "-0100";}
197  if (TmZoneStr=="NDT"){/* Newfoundland Daylight Time North America */ return "-0230";}
198  if (TmZoneStr=="NFT"){/* Norfolk (Island) Time Australia */ return "+ 11:30";}
199  if (TmZoneStr=="NST"){/* Newfoundland Standard Time North America */ return "-0330";}
200  if (TmZoneStr=="O"){/* Oscar Time Zone Military */ return "-0200";}
201  if (TmZoneStr=="P"){/* Papa Time Zone Military */ return "-0300";}
202  if (TmZoneStr=="PDT"){/* Pacific Daylight Time North America */ return "-0700";}
203  if (TmZoneStr=="PST"){/* Pacific Standard Time North America */ return "-0800";}
204  if (TmZoneStr=="Q"){/* Quebec Time Zone Military */ return "-0400";}
205  if (TmZoneStr=="R"){/* Romeo Time Zone Military */ return "-0500";}
206  if (TmZoneStr=="S"){/* Sierra Time Zone Military */ return "-0600";}
207  if (TmZoneStr=="T"){/* Tango Time Zone Military */ return "-0700";}
208  if (TmZoneStr=="U"){/* Uniform Time Zone Military */ return "-0800";}
209  if (TmZoneStr=="UTC"){/* Coordinated Universal Time Europe */ return "+0000";}
210  if (TmZoneStr=="V"){/* Victor Time Zone Military */ return "-0900";}
211  if (TmZoneStr=="W"){/* Whiskey Time Zone Military */ return "-1000";}
212  if (TmZoneStr=="WDT"){/* Western Daylight Time Australia */ return "+0900";}
213  if (TmZoneStr=="WEDT"){/* Western European Daylight Time Europe */ return "+0100";}
214  if (TmZoneStr=="WEST"){/* Western European Summer Time Europe */ return "+0100";}
215  if (TmZoneStr=="WET"){/* Western European Time Europe */ return "+0000";}
216  if (TmZoneStr=="WST"){/* Western Summer Time Australia */ return "+0900";}
217  if (TmZoneStr=="WST"){/* Western Standard Time Australia */ return "+0800";}
218  if (TmZoneStr=="X"){/* X-ray Time Zone Military */ return "-1100";}
219  if (TmZoneStr=="Y"){/* Yankee Time Zone Military */ return "-1200";}
220  if (TmZoneStr=="Z"){/* Zulu Time Zone Military */ return "+0000";}
221  return "-0000";
222 }
223 
224 // day-of-week numbers
225 const int TTmInfo::SunN=1; const int TTmInfo::MonN=2;
226 const int TTmInfo::TueN=3; const int TTmInfo::WedN=4;
227 const int TTmInfo::ThuN=5; const int TTmInfo::FriN=6;
228 const int TTmInfo::SatN=7;
229 
230 // month numbers
231 const int TTmInfo::JanN=1; const int TTmInfo::FebN=2;
232 const int TTmInfo::MarN=3; const int TTmInfo::AprN=4;
233 const int TTmInfo::MayN=5; const int TTmInfo::JunN=6;
234 const int TTmInfo::JulN=7; const int TTmInfo::AugN=8;
235 const int TTmInfo::SepN=9; const int TTmInfo::OctN=10;
236 const int TTmInfo::NovN=11; const int TTmInfo::DecN=12;
237 
239 // Julian-Dates
240 
241 /* public domain Julian Day Number functions
242 **
243 ** Based on formulae originally posted by
244 ** Tom Van Flandern / Washington, DC / metares@well.sf.ca.us
245 ** in the UseNet newsgroup sci.astro.
246 ** Reposted 14 May 1991 in FidoNet C Echo conference by
247 ** Paul Schlyter (Stockholm)
248 ** Minor corrections, added JDN to julian, and recast into C by
249 ** Raymond Gardner Englewood, Colorado
250 **
251 ** Synopsis:
252 ** long ymd_to_jdn(int year, int month, int day, int julian_flag)
253 ** void jdn_to_ymd(long jdn, int *year, int *month, int *day,
254 ** int julian_flag)
255 ** year is negative if BC
256 ** if julian_flag is > 0, use Julian calendar
257 ** if julian_flag is == 0, use Gregorian calendar
258 ** if julian_flag is < 0, routines decide based on date
259 **
260 ** These routines convert Gregorian and Julian calendar dates to and
261 ** from Julian Day Numbers. Julian Day Numbers (JDN) are used by
262 ** astronomers as a date/time measure independent of calendars and
263 ** convenient for computing the elapsed time between dates. The JDN
264 ** for any date/time is the number of days (including fractional
265 ** days) elapsed since noon, 1 Jan 4713 BC. Julian Day Numbers were
266 ** originated by Joseph Scaliger in 1582 and named after his father
267 ** Julius, not after Julius Caesar. They are not related to the
268 ** Julian calendar.
269 **
270 ** For dates from 1 Jan 4713 BC thru 12 Dec Feb 32766 AD, ymd_to_jdn()
271 ** will give the JDN for noon on that date. jdn_to_ymd() will compute
272 ** the year, month, and day from the JDN. Years BC are given (and
273 ** returned) as negative numbers. Note that there is no year 0 BC;
274 ** the day before 1 Jan 1 AD is 31 Dec 1 BC. Note also that 1 BC,
275 ** 5 BC, etc. are leap years.
276 **
277 ** Pope Gregory XIII decreed that the Julian calendar would end on
278 ** 4 Oct 1582 AD and that the next day would be 15 Oct 1582 in the
279 ** Gregorian Calendar. The only other change is that centesimal
280 ** years (years ending in 00) would no longer be leap years
281 ** unless divisible by 400. Britain and its possessions and
282 ** colonies continued to use the Julian calendar up until 2 Sep
283 ** 1752, when the next day became 14 Sep 1752 in the Gregorian
284 ** Calendar. These routines can be compiled to use either
285 ** convention. By default, the British convention will be used.
286 ** Simply #define PAPAL to use Pope Gregory's convention.
287 **
288 ** Each routine takes, as its last argument, a flag to indicate
289 ** whether to use the Julian or Gregorian calendar convention. If
290 ** this flag is negative, the routines decide based on the date
291 ** itself, using the changeover date described in the preceding
292 ** paragraph. If the flag is zero, Gregorian conventions will be used,
293 ** and if the flag is positive, Julian conventions will be used.
294 */
295 
296 // Pope Gregory XIII's decree
297 int TJulianDate::LastJulianDate=15821004; /* last day to use Julian calendar */
298 int TJulianDate::LastJulianDateN=2299160; /* jdn of same */
299 // British-American usage
300 //int TJulianDate::LastJulianDate=17520902; /* last day to use Julian calendar */
301 //int TJulianDate::LastJulianDateN=2361221; /* jdn of same */
302 
303 int TJulianDate::GetJulianDateN(int d, int m, int y){
304  IAssert(y != 0);
305  int julian = -1;
306  long jdn;
307 
308  if (julian < 0){ /* set Julian flag if auto set */
309  julian = (((y * 100L) + m) * 100 + d <= LastJulianDate);}
310 
311  if (y < 0){ /* adjust BC year */
312  y++;}
313 
314  if (julian){
315  jdn = 367L * y - 7 * (y + 5001L + (m - 9) / 7) / 4
316  + 275 * m / 9 + d + 1729777L;
317  } else {
318  jdn = (long)(d - 32076)
319  + 1461L * (y + 4800L + (m - 14) / 12) / 4
320  + 367 * (m - 2 - (m - 14) / 12 * 12) / 12
321  - 3 * ((y + 4900L + (m - 14) / 12) / 100) / 4
322  + 1; /* correction by rdg */
323  }
324  return (int) jdn;
325 }
326 
327 void TJulianDate::GetCalendarDate(int jdn, int& dd, int& mm, int& yy){
328  int julian = -1;
329 
330  long x, z, m, d, y;
331  long daysPer400Years = 146097L;
332  long fudgedDaysPer4000Years = 1460970L + 31;
333 
334  if (julian < 0){ /* set Julian flag if auto set */
335  julian = (jdn <= LastJulianDateN);}
336 
337  x = jdn + 68569L;
338  if (julian){
339  x+=38;
340  daysPer400Years = 146100L;
341  fudgedDaysPer4000Years = 1461000L + 1;
342  }
343  z = 4 * x / daysPer400Years;
344  x = x - (daysPer400Years * z + 3) / 4;
345  y = 4000 * (x + 1) / fudgedDaysPer4000Years;
346  x = x - 1461 * y / 4 + 31;
347  m = 80 * x / 2447;
348  d = x - 2447 * m / 80;
349  x = m / 11;
350  m = m + 2 - 12 * x;
351  y = 100 * (z - 49) + y + x;
352 
353  yy = (int)y;
354  mm = (int)m;
355  dd = (int)d;
356 
357  if (yy <= 0){ /* adjust BC years */
358  (yy)--;}
359 }
360 
362 // Seconds-Time
363 bool TSecTm::GetTmSec(const int& YearN, const int& MonthN, const int& DayN, const int& HourN, const int& MinN, const int& SecN, uint& AbsSec) {
364  AbsSec = 0;
365  // tm_isdst:
366  // - Positive if daylight saving time is in effect;
367  // - 0 if daylight saving time is not in effect;
368  // - negative if status of daylight saving time is unknown.
369  // The C run-time library assumes the United States's rules for implementing
370  // the calculation of Daylight Saving Time (DST).
371  struct tm Tm;
372  Tm.tm_year=YearN-1900; Tm.tm_mon=MonthN-1; Tm.tm_mday=DayN;
373  Tm.tm_hour=HourN; Tm.tm_min=MinN; Tm.tm_sec=SecN;
374  Tm.tm_wday=1; Tm.tm_yday=1;
375  Tm.tm_isdst=-1;
376  return TSecTm::GetTmSec(Tm, AbsSec);
377 }
378 
379 // implementation of mkgmtime (taken from the web)
380 time_t TSecTm::MkGmTime(struct tm *t) {
381  static const int m_to_d[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
382  short month, year;
383  time_t result;
384  month = t->tm_mon;
385  year = t->tm_year + month / 12 + 1900;
386  month %= 12;
387  if (month < 0) {
388  year -= 1;
389  month += 12; }
390  result = (year - 1970) * 365 + (year - 1969) / 4 + m_to_d[month];
391  result = (year - 1970) * 365 + m_to_d[month];
392  if (month <= 1) { year -= 1; }
393  result += (year - 1968) / 4;
394  result -= (year - 1900) / 100;
395  result += (year - 1600) / 400;
396  result += t->tm_mday;
397  result -= 1;
398  result *= 24;
399  result += t->tm_hour;
400  result *= 60;
401  result += t->tm_min;
402  result *= 60;
403  result += t->tm_sec;
404  return result;
405 }
406 
407 bool TSecTm::GetTmSec(struct tm& Tm, uint& AbsSec) {
408  const time_t GmtTime = MkGmTime(&Tm);
409  EAssertR(uint(GmtTime) < TUInt::Mx,
410  TStr::Fmt("Time out of range: %d/%d/%d %02d:%02d:%02d",
411  Tm.tm_year, Tm.tm_mon, Tm.tm_mday, Tm.tm_hour, Tm.tm_min, Tm.tm_sec).CStr());
412  AbsSec = uint(GmtTime);
413  return GmtTime >= 0;
414 }
415 
416 bool TSecTm::GetTmStruct(const uint& AbsSec, struct tm& Tm) {
417  const time_t TimeT = time_t(AbsSec);
418  #if defined(GLib_MSC)
419  return _gmtime64_s(&Tm, &TimeT) == 0;
420  #elif defined(GLib_BCB)
421  Tm=*gmtime(&TimeT); return true;
422  #else
423  return gmtime_r(&TimeT, &Tm) != NULL;
424  #endif
425 }
426 
427 TSecTm::TSecTm(const int& YearN, const int& MonthN, const int& DayN,
428  const int& HourN, const int& MinN, const int& SecN) : AbsSecs(TUInt::Mx){
429  GetTmSec(YearN, MonthN, DayN, HourN, MinN, SecN, AbsSecs.Val);
430 }
431 
432 TSecTm::TSecTm(const TTm& Tm): AbsSecs(
433  TSecTm(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour(),
434  Tm.GetMin(), Tm.GetSec()).GetAbsSecs()) { }
435 
436 TSecTm::TSecTm(const PXmlTok& XmlTok) {
437  const int Year = XmlTok->GetIntArgVal("Year");
438  const int Month = XmlTok->GetIntArgVal("Month");
439  const int Day = XmlTok->GetIntArgVal("Day");
440  const int Hour = XmlTok->GetIntArgVal("Hour");
441  const int Min = XmlTok->GetIntArgVal("Min");
442  const int Sec = XmlTok->GetIntArgVal("Sec");
443  AbsSecs = TSecTm(Year, Month, Day, Hour, Min, Sec).GetAbsSecs();
444 }
445 
447  PXmlTok NodeTok = TXmlTok::New("NodeTime");
448  NodeTok->AddArg("Year", GetYearN());
449  NodeTok->AddArg("Month", GetMonthN());
450  NodeTok->AddArg("Day", GetDayN());
451  NodeTok->AddArg("Hour", GetHourN());
452  NodeTok->AddArg("Min", GetMinN());
453  NodeTok->AddArg("Sec", GetSecN());
454  return NodeTok;
455 }
456 
457 TStr TSecTm::GetStr(const TLoc& Loc) const {
458  if (IsDef()) {
459  struct tm Tm;
460  IAssert(GetTmStruct(AbsSecs(), Tm));
461  // Wed May 14 15:30:17 2003
462  return TStr::Fmt("%s %s %d %02d:%02d:%02d %d",
463  TTmInfo::GetDayOfWeekNm(Tm.tm_wday + 1, Loc).CStr(),
464  TTmInfo::GetMonthNm(Tm.tm_mon + 1, Loc).CStr(),
465  Tm.tm_mday, Tm.tm_hour, Tm.tm_min, Tm.tm_sec, Tm.tm_year+1900);
466  } else {
467  return "Undef";
468  }
469 }
470 
471 TStr TSecTm::GetStr(const TTmUnit& TmUnit) const {
472  if (TmUnit == tmuYear) {
473  return TInt::GetStr(GetYearN()); }
474  else if (TmUnit == tmuMonth) {
475  return TStr::Fmt("%04d-%02d", GetYearN(), GetMonthN()); }
476  else if (TmUnit == tmuDay) {
477  return TStr::Fmt("%04d-%02d-%02d", GetYearN(), GetMonthN(), GetDayN()); }
478  else {
479  return TStr::Fmt("%04d-%02d-%02d %02d:%02d:%02d",
480  GetYearN(), GetMonthN(), GetDayN(), GetHourN(), GetMinN(), GetSecN());
481  }
482 }
483 
484 TStr TSecTm::GetDtStr(const TLoc& Loc) const {
485  if (IsDef()){
486  struct tm Tm;
487  IAssert(GetTmStruct(AbsSecs(), Tm));
488  return TStr::Fmt("%s %s %d %d",
489  TTmInfo::GetDayOfWeekNm(Tm.tm_wday + 1, Loc).CStr(),
490  TTmInfo::GetMonthNm(Tm.tm_mon + 1, Loc).CStr(), Tm.tm_year+1900);
491  } else {
492  return "Undef";
493  }
494 }
495 
497  struct tm Tm;
498  IAssert(GetTmStruct(AbsSecs(), Tm));
499  return TStr::Fmt("%02d/%02d%/%04d", Tm.tm_mon+1, Tm.tm_mday, Tm.tm_year+1900);
500 }
501 
503  struct tm Tm;
504  IAssert(GetTmStruct(AbsSecs(), Tm));
505  return TStr::Fmt("%04d-%02d-%02d", Tm.tm_year+1900, Tm.tm_mon+1, Tm.tm_mday);
506 }
507 
509  struct tm Tm;
510  IAssert(GetTmStruct(AbsSecs(), Tm));
511  return TStr::Fmt("%04d-%02d-%02d %02d:%02d:%02d", Tm.tm_year+1900, Tm.tm_mon+1, Tm.tm_mday, Tm.tm_hour, Tm.tm_min, Tm.tm_sec);
512 }
513 
514 
516  if (IsDef()){
517  struct tm Tm;
518  IAssert(GetTmStruct(AbsSecs(), Tm));
519  return TStr::Fmt("%02d:%02d:%02d", Tm.tm_hour, Tm.tm_min, Tm.tm_sec);
520  } else {
521  return "Undef";
522  }
523 }
524 
526  if (IsDef()){
527  struct tm Tm;
528  IAssert(GetTmStruct(AbsSecs(), Tm));
529  return TStr::Fmt("%02d:%02d", Tm.tm_min, Tm.tm_sec);
530  } else {
531  return "Undef";
532  }
533 }
534 
536  return
537  TInt::GetStr(GetYearN(), "%04d")+"/"+
538  TInt::GetStr(GetMonthN(), "%02d")+"/"+
539  TInt::GetStr(GetDayN(), "%02d")+" "+
540  TInt::GetStr(GetHourN(), "%02d")+":"+
541  TInt::GetStr(GetMinN(), "%02d")+":"+
542  TInt::GetStr(GetSecN(), "%02d");
543 }
544 
546  return
547  TInt::GetStr(GetYearN(), "%04d")+"-"+
548  TInt::GetStr(GetMonthN(), "%02d")+"-"+
549  TInt::GetStr(GetDayN(), "%02d")+"_"+
550  TInt::GetStr(GetHourN(), "%02d")+"-"+
551  TInt::GetStr(GetMinN(), "%02d")+"-"+
552  TInt::GetStr(GetSecN(), "%02d");
553 }
554 
555 int TSecTm::GetYearN() const {
556  struct tm Tm;
557  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
558  return Tm.tm_year+1900;
559 }
560 
561 int TSecTm::GetMonthN() const {
562  struct tm Tm;
563  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
564  return Tm.tm_mon+1;
565 }
566 
567 TStr TSecTm::GetMonthNm(const TLoc& Loc) const {
568  struct tm Tm;
569  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
570  return TTmInfo::GetMonthNm(Tm.tm_mon+1, Loc);
571 }
572 
573 int TSecTm::GetDayN() const {
574  struct tm Tm;
575  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
576  return Tm.tm_mday;
577 }
578 
580  struct tm Tm;
581  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
582  return Tm.tm_wday + 1;
583 }
584 
585 TStr TSecTm::GetDayOfWeekNm(const TLoc& Loc) const {
586  struct tm Tm;
587  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
588  return TTmInfo::GetDayOfWeekNm(Tm.tm_wday+1, Loc);
589 }
590 
591 int TSecTm::GetHourN() const {
592  struct tm Tm;
593  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
594  return Tm.tm_hour;
595 }
596 
597 int TSecTm::GetMinN() const {
598  struct tm Tm;
599  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
600  return Tm.tm_min;
601 }
602 
603 int TSecTm::GetSecN() const {
604  struct tm Tm;
605  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
606  return Tm.tm_sec;
607 }
608 
609 void TSecTm::GetComps(int& Year, int& Month, int& Day, int& Hour, int& Min, int& Sec) const {
610  struct tm Tm;
611  EAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
612  Year = Tm.tm_year+1900;
613  Month = Tm.tm_mon+1;
614  Day = Tm.tm_mday;
615  Hour = Tm.tm_hour;
616  Min = Tm.tm_min;
617  Sec = Tm.tm_sec;
618 }
619 
620 TSecTm TSecTm::Round(const TTmUnit& TmUnit) const {
621  if (TmUnit == tmu1Sec) { return *this; }
622  struct tm Time;
623  IAssert(IsDef() && GetTmStruct(AbsSecs(), Time));
624  switch (TmUnit) {
625  case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0);
626  case tmu10Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 10*(Time.tm_min/10), 0);
627  case tmu15Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 15*(Time.tm_min/15), 0);
628  case tmu30Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 30*(Time.tm_min/30), 0);
629  case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0);
630  case tmu2Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 2*(Time.tm_hour/2), 0, 0);
631  case tmu4Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 4*(Time.tm_hour/4), 0, 0);
632  case tmu6Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 6*(Time.tm_hour/6), 0, 0);
633  case tmu12Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 12*(Time.tm_hour/12), 0, 0);
634  case tmuDay : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 0, 0, 0);
635  case tmuMonth : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, 1, 0, 0, 0);
636  case tmuYear : return TSecTm(Time.tm_year+1900, 1, 1, 0, 0, 0);
637  case tmuWeek : { int dd=1, mm=1, yy=1;
638  // week starts on Thursday, since 1.1.1970 is Thursday
639  const int Day = TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year);
640  TJulianDate::GetCalendarDate(3+7*(Day/7), dd, mm, yy); return TSecTm(yy, mm, dd, 0, 0, 0); }
641  default : Fail;
642  }
643  return TSecTm();
644 }
645 uint TSecTm::GetInUnits(const TTmUnit& TmUnit) const {
646  static const int DayZero = TJulianDate::GetJulianDateN(1, 1, 1970);
647  if (TmUnit == tmu1Sec) { return AbsSecs; }
648  struct tm Time;
649  IAssert(IsDef() && GetTmStruct(AbsSecs(), Time));
650  switch (TmUnit) {
651  case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0).GetAbsSecs()/60;
652  case tmu10Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 10*(Time.tm_min/10), 0).GetAbsSecs()/(10*60);
653  case tmu15Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 15*(Time.tm_min/15), 0).GetAbsSecs()/(15*60);
654  case tmu30Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 30*(Time.tm_min/30), 0).GetAbsSecs()/(30*60);
655  case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0).GetAbsSecs()/3600;
656  case tmu2Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 2*(Time.tm_hour/2), 0, 0).GetAbsSecs()/(2*3600);
657  case tmu4Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 4*(Time.tm_hour/4), 0, 0).GetAbsSecs()/(4*3600);
658  case tmu6Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 6*(Time.tm_hour/6), 0, 0).GetAbsSecs()/(6*3600);
659  case tmu12Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 12*(Time.tm_hour/12), 0, 0).GetAbsSecs()/(12*3600);
660  case tmuDay : return TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year) - DayZero;
661  case tmuWeek : return (TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year)-DayZero)/7;
662  case tmuMonth : return 12*(Time.tm_year-70)+Time.tm_mon+1;
663  case tmuYear : return Time.tm_year+1900;
664  default : Fail;
665  }
666  return TUInt::Mx;
667 }
668 
670  const int Hour = GetHourN();
671  if (0 <= Hour && Hour < 6) { return "Night"; }
672  else if (6 <= Hour && Hour < 12) { return "Morning"; }
673  else if (12 <= Hour && Hour < 18) { return "Afternoon"; }
674  else if (18 <= Hour && Hour < 24) { return "Evening"; }
675  return "";
676 }
677 
678 uint TSecTm::GetDSecs(const TSecTm& SecTm1, const TSecTm& SecTm2){
679  IAssert(SecTm1.IsDef()&&SecTm2.IsDef());
680  const time_t Time1= time_t(SecTm1.AbsSecs());
681  const time_t Time2= time_t(SecTm2.AbsSecs());
682  return uint(difftime(Time2, Time1));
683 }
684 
686  TSecTm ZeroWeekTm=GetZeroTm();
687  while (ZeroWeekTm.GetDayOfWeekN()!=TTmInfo::MonN){
688  ZeroWeekTm.AddDays(1);}
689  return ZeroWeekTm;
690 }
691 
693  const time_t TmSec = time(NULL);
694  struct tm LocTm;
695  uint AbsSec = TUInt::Mx;
696  #if defined(GLib_MSN)
697  localtime_s(&LocTm, &TmSec);
698  #elif defined(GLib_BCB)
699  LocTm = *localtime(&TmSec);
700  #else
701  LocTm = *localtime(&TmSec);
702  #endif
703  IAssert(TSecTm::GetTmSec(LocTm, AbsSec));
704  return TSecTm(AbsSec);
705 }
706 
708  int HmsStrLen=HmsStr.Len();
709  // hour
710  TChA ChA; int ChN=0;
711  while ((ChN<HmsStrLen)&&(HmsStr[ChN]!=':')){ChA+=HmsStr[ChN]; ChN++;}
712  TStr HourStr=ChA;
713  // minute
714  ChA.Clr(); ChN++;
715  while ((ChN<HmsStrLen)&&(HmsStr[ChN]!=':')){ChA+=HmsStr[ChN]; ChN++;}
716  TStr MinStr=ChA;
717  // second
718  ChA.Clr(); ChN++;
719  while (ChN<HmsStrLen){ChA+=HmsStr[ChN]; ChN++;}
720  TStr SecStr=ChA;
721  // transform to numbers
722  int HourN=HourStr.GetInt();
723  int MinN=MinStr.GetInt();
724  int SecN=SecStr.GetInt();
725  // construct the time
727  Tm.AddHours(HourN);
728  Tm.AddMins(MinN);
729  Tm.AddSecs(SecN);
730  return Tm;
731 }
732 
734  int MdyStrLen=MdyStr.Len();
735  // month
736  TChA ChA; int ChN=0;
737  while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){
738  ChA+=MdyStr[ChN]; ChN++;}
739  TStr MonthStr=ChA;
740  // day
741  ChA.Clr(); ChN++;
742  while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){
743  ChA+=MdyStr[ChN]; ChN++;}
744  TStr DayStr=ChA;
745  // year
746  ChA.Clr(); ChN++;
747  while (ChN<MdyStrLen){
748  ChA+=MdyStr[ChN]; ChN++;}
749  TStr YearStr=ChA;
750  // transform to numbers
751  int MonthN=MonthStr.GetInt();
752  int DayN=DayStr.GetInt();
753  int YearN=YearStr.GetInt();
754  if (YearN<1000){
755  if (YearN<70){YearN+=2000;} else {YearN+=1900;}}
756  // construct the date
757  return GetDtTm(YearN, MonthN, DayN);
758 }
759 
760 // parse 28/03/03 and 28-MAY-03 formats
762  int DmyStrLen=DmyStr.Len();
763  // day
764  TChA ChA; int ChN=0;
765  while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){
766  ChA+=DmyStr[ChN]; ChN++;}
767  TStr DayStr=ChA;
768  // month
769  ChA.Clr(); ChN++;
770  while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){
771  ChA+=DmyStr[ChN]; ChN++;}
772  TStr MonthStr=ChA;
773  // year
774  ChA.Clr(); ChN++;
775  while (ChN<DmyStrLen){
776  ChA+=DmyStr[ChN]; ChN++;}
777  TStr YearStr=ChA;
778  // transform to numbers
779  int DayN=DayStr.GetInt(-1);
780  int MonthN=MonthStr.GetInt(-1);
781  int YearN=YearStr.GetInt(-1);
782  if (MonthN == -1){
783  MonthN = TTmInfo::GetMonthN(MonthStr.ToCap()); }
784  if ((DayN==-1)||(MonthN==-1)||(YearN==-1)){
785  return TSecTm();
786  } else {
787  if (YearN<1000){
788  if (YearN<70){YearN+=2000;} else {YearN+=1900;}}
789  // construct the date
790  return GetDtTm(YearN, MonthN, DayN);
791  }
792  return TSecTm();
793 }
794 
796  const char& DateSepCh, const char& TimeSepCh){
797  int MdyHmsPmStrLen=MdyHmsPmStr.Len();
798  // month
799  TChA ChA; int ChN=0;
800  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){
801  ChA+=MdyHmsPmStr[ChN]; ChN++;}
802  TStr MonthStr=ChA;
803  // day
804  ChA.Clr(); ChN++;
805  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){
806  ChA+=MdyHmsPmStr[ChN]; ChN++;}
807  TStr DayStr=ChA;
808  // year
809  ChA.Clr(); ChN++;
810  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){
811  ChA+=MdyHmsPmStr[ChN]; ChN++;}
812  TStr YearStr=ChA;
813  // hour
814  ChA.Clr(); ChN++;
815  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){
816  ChA+=MdyHmsPmStr[ChN]; ChN++;}
817  TStr HourStr=ChA;
818  // minute
819  ChA.Clr(); ChN++;
820  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){
821  ChA+=MdyHmsPmStr[ChN]; ChN++;}
822  TStr MinStr=ChA;
823  // second
824  ChA.Clr(); ChN++;
825  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){
826  ChA+=MdyHmsPmStr[ChN]; ChN++;}
827  TStr SecStr=ChA;
828  // AM/PM
829  ChA.Clr(); ChN++;
830  while (ChN<MdyHmsPmStrLen){
831  ChA+=MdyHmsPmStr[ChN]; ChN++;}
832  TStr AmPmStr=ChA;
833  // transform to numbers
834  int MonthN=MonthStr.GetInt();
835  int DayN=DayStr.GetInt();
836  int YearN=YearStr.GetInt();
837  int HourN; int MinN; int SecN;
838  if (HourStr.IsInt()){
839  HourN=HourStr.GetInt();
840  MinN=MinStr.GetInt();
841  SecN=SecStr.GetInt();
842  if (AmPmStr=="AM"){} else if (AmPmStr=="PM"){HourN+=12;} else {Fail;}
843  } else {
844  HourN=0; MinN=0; SecN=0;
845  }
846  // construct the time
847  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
848  Tm.AddHours(HourN);
849  Tm.AddMins(MinN);
850  Tm.AddSecs(SecN);
851  return Tm;
852 }
853 
855  const char& DateSepCh, const char& TimeSepCh){
856  int YmdHmsPmStrLen=YmdHmsPmStr.Len();
857  // year
858  TChA ChA; int ChN=0;
859  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
860  ChA+=YmdHmsPmStr[ChN]; ChN++;}
861  TStr YearStr=ChA;
862  // month
863  ChA.Clr(); ChN++;
864  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
865  ChA+=YmdHmsPmStr[ChN]; ChN++;}
866  TStr MonthStr=ChA;
867  // day
868  ChA.Clr(); ChN++;
869  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=' ')){
870  ChA+=YmdHmsPmStr[ChN]; ChN++;}
871  TStr DayStr=ChA;
872  // hour
873  ChA.Clr(); ChN++;
874  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
875  ChA+=YmdHmsPmStr[ChN]; ChN++;}
876  TStr HourStr=ChA;
877  // minute
878  ChA.Clr(); ChN++;
879  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
880  ChA+=YmdHmsPmStr[ChN]; ChN++;}
881  TStr MinStr=ChA;
882  // second
883  ChA.Clr(); ChN++;
884  while (ChN<YmdHmsPmStrLen){
885  ChA+=YmdHmsPmStr[ChN]; ChN++;}
886  TStr SecStr=ChA;
887  // transform to numbers
888  int MonthN=MonthStr.GetInt();
889  int DayN=DayStr.GetInt();
890  int YearN=YearStr.GetInt();
891  int HourN; int MinN; int SecN;
892  if (HourStr.IsInt()){
893  HourN=HourStr.GetInt();
894  MinN=MinStr.GetInt();
895  SecN=SecStr.GetInt();
896  } else {
897  HourN=0; MinN=0; SecN=0;
898  }
899  // construct the time
900  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
901  Tm.AddHours(HourN);
902  Tm.AddMins(MinN);
903  Tm.AddSecs(SecN);
904  return Tm;
905 }
906 
907 // Parse strings of the form 2006-08-28 14:11:16 or 14:11:16 08/28/2008
908 // Non-numeric characters act as separators (there can be many consecutive separating characters)
909 // Variables give indexes of the date fields
910 TSecTm TSecTm::GetDtTmFromStr(const TChA& YmdHmsPmStr, const int& YearId, const int& MonId,
911  const int& DayId, const int& HourId, const int& MinId, const int& SecId) {
912  TChA Tmp = YmdHmsPmStr;
913  TVec<char *> FldV;
914  // get the sequences of numbers
915  for (char *c = (char *) Tmp.CStr(); *c; c++) {
916  if (TCh::IsNum(*c)) {
917  FldV.Add(c);
918  while (TCh::IsNum(*c)) { c++; }
919  c--;
920  } else { *c = 0; }
921  }
922  const int Y = atoi(FldV[YearId]);
923  const int M = atoi(FldV[MonId]);
924  const int D = atoi(FldV[DayId]);
925  const int H = atoi(FldV[HourId]);
926  const int m = atoi(FldV[MinId]);
927  const int S = atoi(FldV[SecId]);
928  IAssert(Y>0 && M>0 && D>0 && M<13 && D<32);
929  IAssert(H>=0 && H<24 && m>=0 && m<60 && S>=0 && S<60);
930  return TSecTm(Y,M,D,H,m,S);
931 }
932 
933 TSecTm TSecTm::GetDtTm(const int& YearN, const int& MonthN, const int& DayN){
934  uint AbsSecs;
935  TSecTm::GetTmSec(YearN, MonthN, DayN, 0, 0, 0, AbsSecs);
936  return TSecTm(AbsSecs);
937 }
938 
940  int DaySecs=Tm.GetHourN()*3600+Tm.GetMinN()*60+Tm.GetSecN();
941  TSecTm DtTm(Tm.AbsSecs-DaySecs);
942  return DtTm;
943 }
944 
946  return TSecTm(Lx.GetInt());
947 }
948 
949 void TSecTm::SaveTxt(TOLx& Lx) const {
950  IAssert(int(AbsSecs) < TInt::Mx);
951  Lx.PutInt((int)AbsSecs);
952 }
953 
955 // Date-Time
956 TStr TTm::GetStr(const bool& MSecP) const {
957  TChA ChA;
958  ChA+=TInt::GetStr(Year, "%04d"); ChA+='-';
959 // ChA+=GetMonthNm(); ChA+='-';
960  ChA+=TInt::GetStr(Month, "%02d"); ChA+='-';
961  ChA+=TInt::GetStr(Day, "%02d"); ChA+=' ';
962 // ChA+=GetDayOfWeekNm(); ChA+=' ';
963  ChA+=TInt::GetStr(Hour, "%02d"); ChA+=':';
964  ChA+=TInt::GetStr(Min, "%02d"); ChA+=':';
965  ChA+=TInt::GetStr(Sec, "%02d");
966  if (MSecP){ChA+='.'; ChA+=TInt::GetStr(MSec, "%03d");}
967  return ChA;
968 }
969 
971  TChA ChA;
972  ChA+=TInt::GetStr(Year, "%04d");
973  ChA+='-'; ChA+=TInt::GetStr(Month, "%02d");
974  ChA+='-'; ChA+=TInt::GetStr(Day, "%02d");
975  return ChA;
976 }
977 
978 TStr TTm::GetHMSTColonDotStr(const bool& FullP, const bool& MSecP) const {
979  TChA ChA;
980  ChA+=TInt::GetStr(Hour, "%02d");
981  ChA+=':'; ChA+=TInt::GetStr(Min, "%02d");
982  if (FullP||((Sec!=0)||(MSec!=0))){
983  ChA+=':'; ChA+=TInt::GetStr(Sec, "%02d");
984  if ((MSecP)&&(FullP||(MSec!=0))){
985  ChA+='.'; ChA+=TInt::GetStr(MSec, "%d");
986  }
987  }
988  return ChA;
989 }
990 
992  TChA ChA;
993  ChA+=TInt::GetStr(Year%100, "%02d");
994  ChA+=TInt::GetStr(Month, "%02d");
995  ChA+=TInt::GetStr(Day, "%02d");
996  ChA+=TInt::GetStr(Hour, "%02d");
997  ChA+=TInt::GetStr(Min, "%02d");
998  ChA+=TInt::GetStr(Sec, "%02d");
999  ChA+=TInt::GetStr(MSec, "%03d");
1000  return ChA;
1001 }
1002 
1003 
1004 void TTm::AddTime(const int& Hours,
1005  const int& Mins, const int& Secs, const int& MSecs){
1006  uint64 TmMSecs=TTm::GetMSecsFromTm(*this);
1007  TmMSecs+=(uint64(Hours)*uint64(3600)*uint64(1000));
1008  TmMSecs+=(uint64(Mins)*uint64(60)*uint64(1000));
1009  TmMSecs+=(uint64(Secs)*uint64(1000));
1010  TmMSecs+=uint64(MSecs);
1011  *this=GetTmFromMSecs(TmMSecs);
1012 }
1013 
1014 void TTm::SubTime(const int& Hours,
1015  const int& Mins, const int& Secs, const int& MSecs){
1016  uint64 TmMSecs=TTm::GetMSecsFromTm(*this);
1017  TmMSecs-=(uint64(Hours)*uint64(3600)*uint64(1000));
1018  TmMSecs-=(uint64(Mins)*uint64(60)*uint64(1000));
1019  TmMSecs-=(uint64(Secs)*uint64(1000));
1020  TmMSecs-=(uint64(MSecs));
1021  *this=GetTmFromMSecs(TmMSecs);
1022 }
1023 
1025  return TSysTm::GetCurUniTm();
1026 }
1027 
1029  static TTm LastUniqueTm=TSysTm::GetCurUniTm();
1030  TTm CurUniqueTm=TSysTm::GetCurUniTm();
1031  if (CurUniqueTm<LastUniqueTm){CurUniqueTm=LastUniqueTm;}
1032  if (CurUniqueTm==LastUniqueTm){CurUniqueTm.AddTime(0, 0, 0, 1);}
1033  LastUniqueTm=CurUniqueTm;
1034  return CurUniqueTm;
1035 }
1036 
1037 TTm TTm::GetUniqueCurUniTm(const int& UniqueSpaces, const int& UniqueSpaceN){
1038  static uint64 LastMUniqueTmMSecs=TSysTm::GetCurUniMSecs();
1039  // uniqueness-space-parameters range-check
1040  Assert(UniqueSpaces>=1&&UniqueSpaceN>=0&&UniqueSpaceN<UniqueSpaces);
1041  // get current time
1042  uint64 CurUniqueTmMSecs=TSysTm::GetCurUniMSecs();
1043  if (CurUniqueTmMSecs<LastMUniqueTmMSecs){CurUniqueTmMSecs=LastMUniqueTmMSecs;}
1044  // normalize to uniqueness-space-grid
1045  CurUniqueTmMSecs-=CurUniqueTmMSecs%UniqueSpaces; CurUniqueTmMSecs+=UniqueSpaceN;
1046  // get next free unique-time
1047  if (CurUniqueTmMSecs<=LastMUniqueTmMSecs){
1048  CurUniqueTmMSecs+=UniqueSpaces;
1049  }
1050  // update last-time
1051  LastMUniqueTmMSecs=CurUniqueTmMSecs;
1052  return GetTmFromMSecs(CurUniqueTmMSecs);
1053 }
1054 
1056  return TSysTm::GetCurLocTm();
1057 }
1058 
1060  return TSysTm::GetCurUniMSecs();
1061 }
1062 
1064  return TSysTm::GetCurLocMSecs();
1065 }
1066 
1068  return TSysTm::GetMSecsFromTm(Tm);
1069 }
1070 
1072  return TSysTm::GetTmFromMSecs(MSecs);
1073 }
1074 
1076  return TSysTm::GetMSecsFromOsStart();
1077 }
1078 
1080  return TSysTm::GetPerfTimerFq();
1081 }
1082 
1084  return TSysTm::GetPerfTimerTicks();
1085 }
1086 
1087 void TTm::GetDiff(const TTm& Tm1, const TTm& Tm2, int& Days,
1088  int& Hours, int& Mins, int& Secs, int& MSecs) {
1089 
1090  const uint64 DiffMSecs = TTm::GetDiffMSecs(Tm1, Tm2);
1091  const uint64 DiffSecs = DiffMSecs / 1000;
1092  const uint64 DiffMins = DiffSecs / 60;
1093  const uint64 DiffHours = DiffMins / 60;
1094 
1095  MSecs = int(DiffMSecs % 1000);
1096  Secs = int(DiffSecs % 60);
1097  Mins = int(DiffMins % 60);
1098  Hours = int(DiffHours % 24);
1099  Days = int((int)DiffHours / 24);
1100 }
1101 
1102 uint64 TTm::GetDiffMSecs(const TTm& Tm1, const TTm& Tm2){
1103  uint64 Tm1MSecs=GetMSecsFromTm(Tm1);
1104  uint64 Tm2MSecs=GetMSecsFromTm(Tm2);
1105  if (Tm1MSecs>Tm2MSecs){
1106  return Tm1MSecs-Tm2MSecs;
1107  } else {
1108  return Tm2MSecs-Tm1MSecs;
1109  }
1110 }
1111 
1113  return TSysTm::GetLocTmFromUniTm(Tm);
1114 }
1115 
1117  return TSysTm::GetUniTmFromLocTm(Tm);
1118 }
1119 
1121  const char TimeSepCh, const char MSecSepCh){
1122  int TimeStrLen=TimeStr.Len();
1123  // year
1124  TChA ChA; int ChN=0;
1125  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
1126  ChA+=TimeStr[ChN]; ChN++;}
1127  TStr HourStr=ChA;
1128  // minute
1129  ChA.Clr(); ChN++;
1130  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
1131  ChA+=TimeStr[ChN]; ChN++;}
1132  TStr MinStr=ChA;
1133  // second
1134  ChA.Clr(); ChN++;
1135  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=MSecSepCh)){
1136  ChA+=TimeStr[ChN]; ChN++;}
1137  TStr SecStr=ChA;
1138  // mili-second
1139  ChA.Clr(); ChN++;
1140  while (ChN<TimeStrLen){
1141  ChA+=TimeStr[ChN]; ChN++;}
1142  TStr MSecStr=ChA;
1143  // transform to numbers
1144  int HourN=HourStr.GetInt(0);
1145  int MinN=MinStr.GetInt(0);
1146  int SecN=SecStr.GetInt(0);
1147  int MSecN=MSecStr.GetInt(0);
1148  // construct time
1149  TTm Tm(-1, -1, -1, -1, HourN, MinN, SecN, MSecN);
1150  // return time
1151  return Tm;
1152 }
1153 
1155  const char DateSepCh, const char TimeSepCh, const char MSecSepCh,
1156  const char DateTimeSepCh){
1157  int DateTimeStrLen=DateTimeStr.Len();
1158  // year
1159  TChA ChA; int ChN=0;
1160  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateSepCh)){
1161  ChA+=DateTimeStr[ChN]; ChN++;}
1162  TStr YearStr=ChA;
1163  // month
1164  ChA.Clr(); ChN++;
1165  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateSepCh)){
1166  ChA+=DateTimeStr[ChN]; ChN++;}
1167  TStr MonthStr=ChA;
1168  // day
1169  ChA.Clr(); ChN++;
1170  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateTimeSepCh)){
1171  ChA+=DateTimeStr[ChN]; ChN++;}
1172  TStr DayStr=ChA;
1173  // hour
1174  ChA.Clr(); ChN++;
1175  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=TimeSepCh)){
1176  ChA+=DateTimeStr[ChN]; ChN++;}
1177  TStr HourStr=ChA;
1178  // minute
1179  ChA.Clr(); ChN++;
1180  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=TimeSepCh)){
1181  ChA+=DateTimeStr[ChN]; ChN++;}
1182  TStr MinStr=ChA;
1183  // second
1184  ChA.Clr(); ChN++;
1185  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=MSecSepCh)){
1186  ChA+=DateTimeStr[ChN]; ChN++;}
1187  TStr SecStr=ChA;
1188  // mili-second
1189  ChA.Clr(); ChN++;
1190  while (ChN<DateTimeStrLen){
1191  ChA+=DateTimeStr[ChN]; ChN++;}
1192  TStr MSecStr=ChA;
1193  // transform to numbers
1194  int YearN=YearStr.GetInt(-1);
1195  int MonthN=MonthStr.GetInt(-1);
1196  int DayN=DayStr.GetInt(-1);
1197  int HourN=HourStr.GetInt(0);
1198  int MinN=MinStr.GetInt(0);
1199  int SecN=SecStr.GetInt(0);
1200  int MSecN=MSecStr.GetInt(0);
1201  // construct time
1202  TTm Tm;
1203  if ((YearN!=-1)&&(MonthN!=-1)&&(DayN!=-1)){
1204  Tm=TTm(YearN, MonthN, DayN, -1, HourN, MinN, SecN, MSecN);
1205  }
1206  // return time
1207  return Tm;
1208 }
1209 
1211  // normalize
1212  TChA IdChA=IdStr;
1213  if (IdChA.Len()==14){
1214  IdChA.Ins(0, "0");}
1215  // check
1216  IAssert(IdChA.Len()==15);
1217  for (int ChN=0; ChN<IdChA.Len(); ChN++){
1218  IAssert(TCh::IsNum(IdChA[ChN]));}
1219  // extract parts
1220  int YearN=2000+(TStr(IdChA[0])+TStr(IdChA[1])).GetInt();
1221  int MonthN=(TStr(IdChA[2])+TStr(IdChA[3])).GetInt();
1222  int DayN=(TStr(IdChA[4])+TStr(IdChA[5])).GetInt();
1223  int HourN=(TStr(IdChA[6])+TStr(IdChA[7])).GetInt();
1224  int MinN=(TStr(IdChA[8])+TStr(IdChA[9])).GetInt();
1225  int SecN=(TStr(IdChA[10])+TStr(IdChA[11])).GetInt();
1226  int MSecN=(TStr(IdChA[12])+TStr(IdChA[13])+TStr(IdChA[14])).GetInt();
1227  TTm Tm=TTm(YearN, MonthN, DayN, -1, HourN, MinN, SecN, MSecN);
1228  return Tm;
1229 }
1230 
1231 uint TTm::GetDateTimeInt(const int& Year, const int& Month,
1232  const int& Day, const int& Hour, const int& Min, const int& Sec) {
1233 
1234  return TSecTm(Year, Month, Day, Hour, Min, Sec).GetAbsSecs();
1235 }
1236 
1238  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay()) : 0;
1239 }
1240 
1242  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear(), Tm.GetMonth()) : 0;
1243 }
1244 
1246  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear()) : 0;
1247 }
1248 
1250  return Tm.IsDef() ?
1251  GetDateTimeInt(Tm.GetYear(), Tm.GetMonth(),
1252  Tm.GetDay(), Tm.GetHour(), Tm.GetMin(), Tm.GetSec()) : 0;
1253 }
1254 
1255 TTm TTm::GetTmFromDateTimeInt(const uint& DateTimeInt) {
1256  if (DateTimeInt == 0) { return TTm(); }
1257  return TTm(TSecTm(DateTimeInt));
1258 }
1259 
1261  if (DateTimeInt == 0) { return TSecTm(); }
1262  return TSecTm(DateTimeInt);
1263 }
1264 
1266 // Time-Profiler - poor-man's profiler
1267 int TTmProfiler::AddTimer(const TStr& TimerNm) {
1268  MxNmLen = TInt::GetMx(MxNmLen, TimerNm.Len());
1269  return TimerH.AddKey(TimerNm);
1270 }
1271 
1273  int TimerId = GetTimerIdFFirst();
1274  while (GetTimerIdFNext(TimerId)) {
1275  ResetTimer(TimerId);
1276  }
1277 }
1278 
1280  double Sum = 0.0;
1281  int TimerId = GetTimerIdFFirst();
1282  while (GetTimerIdFNext(TimerId)) {
1283  Sum += GetTimerSec(TimerId);
1284  }
1285  return Sum;
1286 }
1287 
1288 double TTmProfiler::GetTimerSec(const int& TimerId) const {
1289  return TimerH[TimerId].GetSec();
1290 }
1291 
1292 void TTmProfiler::PrintReport(const TStr& ProfileNm) const {
1293  const double TimerSumSec = GetTimerSumSec();
1294  printf("-- %s --\n", ProfileNm.CStr());
1295  printf("Sum: (%.2f sec):\n", TimerSumSec);
1296  int TimerId = GetTimerIdFFirst();
1297  while (GetTimerIdFNext(TimerId)) {
1298  // get timer name
1299  TStr TimerNm = GetTimerNm(TimerId);
1300  TimerNm = TStr::GetSpaceStr(TimerNm.Len() - MxNmLen) + TimerNm;
1301  // get timer time and precentage
1302  if (TimerSumSec > 0.0) {
1303  const double TimerSec = GetTimerSec(TimerId);
1304  const double TimerPerc = TimerSec / TimerSumSec * 100.0;
1305  printf(" %s: %.2fs [%.2f%%]\n", TimerNm.CStr(), TimerSec, TimerPerc);
1306  } else {
1307  printf(" %s: -\n", TimerNm.CStr());
1308  }
1309  }
1310  printf("--\n");
1311 }
#define IAssert(Cond)
Definition: bd.h:262
double GetTimerSec(const int &TimerId) const
Definition: tm.cpp:1288
void GetComps(int &Year, int &Month, int &Day, int &Hour, int &Min, int &Sec) const
Definition: tm.cpp:609
int GetInt() const
Definition: dt.h:579
int GetMin() const
Definition: tm.h:281
static TStrV UsMonthNmV
Definition: tm.h:24
static TStrV SiDayOfWeekNmV
Definition: tm.h:27
TInt MSec
Definition: tm.h:215
bool GetTimerIdFNext(int &TimerId) const
Definition: tm.h:413
int GetMinN() const
Definition: tm.cpp:597
TStr GetStr() const
Definition: dt.h:1105
static TStr GetSpaceStr(const int &Spaces)
Definition: dt.cpp:1608
static TSecTm GetDtTmFromStr(const TChA &YmdHmsPmStr, const int &YearId=0, const int &MonId=1, const int &DayId=2, const int &HourId=3, const int &MinId=4, const int &SecId=5)
Definition: tm.cpp:910
static void GetCalendarDate(int jdn, int &dd, int &mm, int &yy)
Definition: tm.cpp:327
TSecTm & AddDays(const int &Days)
Definition: tm.h:167
static TSecTm GetDtTmFromYmdHmsStr(const TStr &YmdHmsPmStr, const char &DateSepCh='-', const char &TimeSepCh=':')
Definition: tm.cpp:854
int Len() const
Definition: dt.h:487
static uint64 GetCurLocMSecs()
Definition: tm.cpp:1063
static void InitDayOfWeekNmV()
Definition: tm.cpp:24
bool IsInt(const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
Definition: dt.cpp:1159
static uint GetDateIntFromTm(const TTm &Tm)
Definition: tm.cpp:1237
void Ins(const int &BChN, const char *CStr)
Definition: dt.cpp:407
double GetTimerSumSec() const
Definition: tm.cpp:1279
int GetMonth() const
Definition: tm.h:275
static bool IsNum(const char &Ch)
Definition: dt.h:972
static void GetDiff(const TTm &Tm1, const TTm &Tm2, int &Days, int &Hours, int &Mins, int &Secs, int &MSecs)
Definition: tm.cpp:1087
static int GetJulianDateN(int d, int m, int y)
Definition: tm.cpp:303
static void EnsureInit()
Definition: tm.h:30
static void InitMonthNmV()
Definition: tm.cpp:9
Definition: tm.h:13
Definition: tm.h:13
int GetYearN() const
Definition: tm.cpp:555
bool IsDef() const
Definition: tm.h:123
Definition: tm.h:12
static const uint Mx
Definition: dt.h:1152
TStr GetYMDDashStr() const
Definition: tm.cpp:970
static TTm GetUniTmFromLocTm(const TTm &Tm)
Definition: tm.cpp:1116
static TSecTm GetDtTmFromHmsStr(const TStr &HmsStr)
Definition: tm.cpp:707
static int LastJulianDate
Definition: tm.h:71
unsigned int uint
Definition: bd.h:11
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1090
static uint64 GetCurUniMSecs()
Definition: tm.cpp:1059
void ResetAll()
Definition: tm.cpp:1272
static const int Mx
Definition: dt.h:1047
#define Fail
Definition: bd.h:238
int GetDayOfWeekN() const
Definition: tm.cpp:579
static PXmlTok New()
Definition: xml.h:212
void Clr()
Definition: dt.h:258
TInt Day
Definition: tm.h:214
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
Definition: tm.h:14
TSecTm & AddMins(const int &Mins)
Definition: tm.h:159
static int GetTmUnitSecs(const TTmUnit &TmUnit)
Definition: tm.cpp:85
static TTm GetCurUniTm()
Definition: tm.cpp:1024
void PutInt(const TInt &Int)
Definition: lx.h:277
PXmlTok GetXmlTok() const
Definition: tm.cpp:446
static uint GetDateTimeIntFromTm(const TTm &Tm)
Definition: tm.cpp:1249
TStr GetDtYmdStr() const
Definition: tm.cpp:502
int Len() const
Definition: dt.h:259
Definition: tm.h:13
static const int JanN
Definition: tm.h:53
int GetInt()
Definition: lx.h:181
uint GetInUnits(const TTmUnit &TmUnit) const
Definition: tm.cpp:645
void SaveTxt(TOLx &Lx) const
Definition: tm.cpp:949
Definition: tm.h:13
static const int OctN
Definition: tm.h:57
TStr GetTmMinStr() const
Definition: tm.cpp:525
static const int JulN
Definition: tm.h:56
static uint GetDateTimeInt(const int &Year=0, const int &Month=0, const int &Day=1, const int &Hour=0, const int &Min=0, const int &Sec=0)
Definition: tm.cpp:1231
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.cpp:1102
static TTm GetTmFromDateTimeInt(const uint &DateTimeInt)
Definition: tm.cpp:1255
static TTm GetTmFromWebLogDateTimeStr(const TStr &DateTimeStr, const char DateSepCh='-', const char TimeSepCh=':', const char MSecSepCh='.', const char DateTimeSepCh=' ')
Definition: tm.cpp:1154
TInt Sec
Definition: tm.h:215
TStr & ToCap()
Definition: dt.cpp:764
TStr GetDtTmSortFNmStr() const
Definition: tm.cpp:545
int GetHour() const
Definition: tm.h:280
int GetMonthN() const
Definition: tm.cpp:561
TInt Min
Definition: tm.h:215
static TSecTm GetDtTmFromDmyStr(const TStr &DmyStr)
Definition: tm.cpp:761
TStr GetIdStr() const
Definition: tm.cpp:991
Definition: tm.h:12
Definition: tm.h:12
static TSecTm GetSecTmFromDateTimeInt(const uint &DateTimeInt)
Definition: tm.cpp:1260
Definition: tm.h:13
static const int NovN
Definition: tm.h:58
Definition: tm.h:14
static const int AprN
Definition: tm.h:54
static TStr GetDayOfWeekNm(const int &DayOfWeekN, const TLoc &Loc=lUs)
Definition: tm.cpp:71
static TSecTm GetDtTmFromMdyStr(const TStr &MdyStr)
Definition: tm.cpp:733
Definition: bd.h:63
static const int ThuN
Definition: tm.h:49
TSecTm()
Definition: tm.h:92
static bool InitP
Definition: tm.h:23
int GetYear() const
Definition: tm.h:274
int AddTimer(const TStr &TimerNm)
Definition: tm.cpp:1267
static uint GetYearIntFromTm(const TTm &Tm)
Definition: tm.cpp:1245
static bool GetTmSec(const int &YearN, const int &MonthN, const int &DayN, const int &HourN, const int &MinN, const int &SecN, uint &AbsSec)
Definition: tm.cpp:363
TInt Hour
Definition: tm.h:215
static TTm GetTmFromIdStr(const TStr &IdStr)
Definition: tm.cpp:1210
char * CStr()
Definition: dt.h:255
static const int MayN
Definition: tm.h:55
TTm()
Definition: tm.h:217
TInt Month
Definition: tm.h:214
void PrintReport(const TStr &ProfileNm="") const
Definition: tm.cpp:1292
unsigned long long uint64
Definition: bd.h:38
TLoc
Definition: bd.h:63
int GetDay() const
Definition: tm.h:277
int GetTimerIdFFirst() const
Definition: tm.h:412
Definition: lx.h:129
uint GetAbsSecs() const
Definition: tm.h:149
int GetSecN() const
Definition: tm.cpp:603
#define Assert(Cond)
Definition: bd.h:251
Definition: lx.h:251
static const int SepN
Definition: tm.h:57
int GetHourN() const
Definition: tm.cpp:591
bool IsDef() const
Definition: tm.h:264
void AddArg(const TStr &ArgNm, const bool &ArgVal)
Definition: xml.h:252
int GetDayN() const
Definition: tm.cpp:573
int GetIntArgVal(const TStr &ArgNm, const int &DfVal=0) const
Definition: xml.cpp:1109
static uint GetMSecsFromOsStart()
Definition: tm.cpp:1075
TStr GetLc() const
Definition: dt.h:499
static TStrV UsDayOfWeekNmV
Definition: tm.h:26
static time_t MkGmTime(struct tm *t)
Definition: tm.cpp:380
Definition: tm.h:14
static uint64 GetPerfTimerTicks()
Definition: tm.cpp:1083
static TTm GetCurLocTm()
Definition: tm.cpp:1055
static TStr GetNullStr()
Definition: dt.cpp:1626
static const int DecN
Definition: tm.h:58
TStr GetDayOfWeekNm(const TLoc &Loc=lUs) const
Definition: tm.cpp:585
TInt Year
Definition: tm.h:214
Definition: tm.h:212
TSecTm & AddSecs(const int &Secs)
Definition: tm.h:155
Definition: dt.h:201
#define EAssert(Cond)
Definition: bd.h:280
Definition: dt.h:1147
static TStr GetMonthNm(const int &MonthN, const TLoc &Loc=lUs)
Definition: tm.cpp:50
TUInt AbsSecs
Definition: tm.h:83
static TSecTm GetZeroWeekTm()
Definition: tm.cpp:685
Definition: tm.h:81
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:933
static TStrV SiMonthNmV
Definition: tm.h:25
int AddKey(const TKey &Key)
Definition: hash.h:327
TInt MxNmLen
Definition: tm.h:401
Definition: tm.h:12
static TStr GetTmZoneDiffStr(const TStr &TmZoneStr)
Definition: tm.cpp:131
static TSecTm LoadTxt(TILx &Lx)
Definition: tm.cpp:945
TStr GetTimerNm(const int &TimerId) const
Definition: tm.h:410
static TStr GetTmUnitStr(const TTmUnit &TmUnit)
Definition: tm.cpp:108
int GetSec() const
Definition: tm.h:282
TStr GetDtTmSortStr() const
Definition: tm.cpp:535
static uint GetMonthIntFromTm(const TTm &Tm)
Definition: tm.cpp:1241
TStr GetMonthNm(const TLoc &Loc=lUs) const
Definition: tm.cpp:567
Definition: dt.h:412
static TTm GetUniqueCurUniTm()
Definition: tm.cpp:1028
static TTm GetTmFromWebLogTimeStr(const TStr &TimeStr, const char TimeSepCh=':', const char MSecSepCh='.')
Definition: tm.cpp:1120
TStr GetStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:457
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static const int FriN
Definition: tm.h:49
static const int WedN
Definition: tm.h:48
static int GetMonthN(const TStr &MonthNm, const TLoc &Loc=lUs)
Definition: tm.cpp:39
TStr GetDtStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:484
TSizeTy SearchForw(const TVal &Val, const TSizeTy &BValN=0) const
Returns the position of an element with value Val.
Definition: ds.h:1440
static const int AugN
Definition: tm.h:56
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
void ResetTimer(const TStr &TimerNm)
Definition: tm.h:422
TStr GetHMSTColonDotStr(const bool &FullP=false, const bool &MSecP=true) const
Definition: tm.cpp:978
static TSecTm GetCurTm()
Definition: tm.cpp:692
TStr GetTmStr() const
Definition: tm.cpp:515
static TTm GetTmFromMSecs(const uint64 &MSecs)
Definition: tm.cpp:1071
Definition: bd.h:63
static uint GetDSecs(const TSecTm &SecTm1, const TSecTm &SecTm2)
Definition: tm.cpp:678
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
uint Val
Definition: dt.h:1149
void AddTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1004
Definition: tm.h:12
static TSecTm GetDtTmFromMdyHmsPmStr(const TStr &MdyHmsPmStr, const char &DateSepCh='/', const char &TimeSepCh=':')
Definition: tm.cpp:795
Definition: tm.h:13
static int GetDayOfWeekN(const TStr &DayOfWeekNm, const TLoc &Loc=lUs)
Definition: tm.cpp:60
TStr GetDayPart() const
Definition: tm.cpp:669
static const int SunN
Definition: tm.h:47
static uint64 GetPerfTimerFq()
Definition: tm.cpp:1079
char * CStr()
Definition: dt.h:476
TTmUnit
Definition: tm.h:11
TStr GetYmdTmStr() const
Definition: tm.cpp:508
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
static const int MonN
Definition: tm.h:47
TStr GetStr(const bool &MSecP=true) const
Definition: tm.cpp:956
TSecTm & AddHours(const int &Hours)
Definition: tm.h:163
void SubTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1014
static uint64 GetMSecsFromTm(const TTm &Tm)
Definition: tm.cpp:1067
static TStr GetHmFromMins(const int &Mins)
Definition: tm.cpp:81
static const int FebN
Definition: tm.h:53
static const int MarN
Definition: tm.h:54
static const int TueN
Definition: tm.h:48
TStr GetDtMdyStr() const
Definition: tm.cpp:496
static const int JunN
Definition: tm.h:55
static int LastJulianDateN
Definition: tm.h:72
static TTm GetLocTmFromUniTm(const TTm &Tm)
Definition: tm.cpp:1112
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420
Definition: tm.h:14
TSecTm Round(const TTmUnit &TmUnit) const
Definition: tm.cpp:620
Definition: tm.h:13
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
static const int SatN
Definition: tm.h:50
static TSecTm GetZeroTm()
Definition: tm.h:186