SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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 
515  struct tm Tm;
516  IAssert(GetTmStruct(AbsSecs(), Tm));
517  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);
518 }
519 
521  if (IsDef()){
522  struct tm Tm;
523  IAssert(GetTmStruct(AbsSecs(), Tm));
524  return TStr::Fmt("%02d:%02d:%02d", Tm.tm_hour, Tm.tm_min, Tm.tm_sec);
525  } else {
526  return "Undef";
527  }
528 }
529 
531  if (IsDef()){
532  struct tm Tm;
533  IAssert(GetTmStruct(AbsSecs(), Tm));
534  return TStr::Fmt("%02d:%02d", Tm.tm_min, Tm.tm_sec);
535  } else {
536  return "Undef";
537  }
538 }
539 
541  return
542  TInt::GetStr(GetYearN(), "%04d")+"/"+
543  TInt::GetStr(GetMonthN(), "%02d")+"/"+
544  TInt::GetStr(GetDayN(), "%02d")+" "+
545  TInt::GetStr(GetHourN(), "%02d")+":"+
546  TInt::GetStr(GetMinN(), "%02d")+":"+
547  TInt::GetStr(GetSecN(), "%02d");
548 }
549 
551  return
552  TInt::GetStr(GetYearN(), "%04d")+"-"+
553  TInt::GetStr(GetMonthN(), "%02d")+"-"+
554  TInt::GetStr(GetDayN(), "%02d")+"_"+
555  TInt::GetStr(GetHourN(), "%02d")+"-"+
556  TInt::GetStr(GetMinN(), "%02d")+"-"+
557  TInt::GetStr(GetSecN(), "%02d");
558 }
559 
560 int TSecTm::GetYearN() const {
561  struct tm Tm;
562  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
563  return Tm.tm_year+1900;
564 }
565 
566 int TSecTm::GetMonthN() const {
567  struct tm Tm;
568  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
569  return Tm.tm_mon+1;
570 }
571 
572 TStr TSecTm::GetMonthNm(const TLoc& Loc) const {
573  struct tm Tm;
574  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
575  return TTmInfo::GetMonthNm(Tm.tm_mon+1, Loc);
576 }
577 
578 int TSecTm::GetDayN() const {
579  struct tm Tm;
580  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
581  return Tm.tm_mday;
582 }
583 
585  struct tm Tm;
586  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
587  return Tm.tm_wday + 1;
588 }
589 
590 TStr TSecTm::GetDayOfWeekNm(const TLoc& Loc) const {
591  struct tm Tm;
592  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
593  return TTmInfo::GetDayOfWeekNm(Tm.tm_wday+1, Loc);
594 }
595 
596 int TSecTm::GetHourN() const {
597  struct tm Tm;
598  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
599  return Tm.tm_hour;
600 }
601 
602 int TSecTm::GetMinN() const {
603  struct tm Tm;
604  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
605  return Tm.tm_min;
606 }
607 
608 int TSecTm::GetSecN() const {
609  struct tm Tm;
610  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
611  return Tm.tm_sec;
612 }
613 
614 void TSecTm::GetComps(int& Year, int& Month, int& Day, int& Hour, int& Min, int& Sec) const {
615  struct tm Tm;
616  EAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
617  Year = Tm.tm_year+1900;
618  Month = Tm.tm_mon+1;
619  Day = Tm.tm_mday;
620  Hour = Tm.tm_hour;
621  Min = Tm.tm_min;
622  Sec = Tm.tm_sec;
623 }
624 
625 TSecTm TSecTm::Round(const TTmUnit& TmUnit) const {
626  if (TmUnit == tmu1Sec) { return *this; }
627  struct tm Time;
628  IAssert(IsDef() && GetTmStruct(AbsSecs(), Time));
629  switch (TmUnit) {
630  case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0);
631  case tmu10Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 10*(Time.tm_min/10), 0);
632  case tmu15Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 15*(Time.tm_min/15), 0);
633  case tmu30Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 30*(Time.tm_min/30), 0);
634  case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0);
635  case tmu2Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 2*(Time.tm_hour/2), 0, 0);
636  case tmu4Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 4*(Time.tm_hour/4), 0, 0);
637  case tmu6Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 6*(Time.tm_hour/6), 0, 0);
638  case tmu12Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 12*(Time.tm_hour/12), 0, 0);
639  case tmuDay : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 0, 0, 0);
640  case tmuMonth : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, 1, 0, 0, 0);
641  case tmuYear : return TSecTm(Time.tm_year+1900, 1, 1, 0, 0, 0);
642  case tmuWeek : { int dd=1, mm=1, yy=1;
643  // week starts on Thursday, since 1.1.1970 is Thursday
644  const int Day = TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year);
645  TJulianDate::GetCalendarDate(3+7*(Day/7), dd, mm, yy); return TSecTm(yy, mm, dd, 0, 0, 0); }
646  default : Fail;
647  }
648  return TSecTm();
649 }
650 uint TSecTm::GetInUnits(const TTmUnit& TmUnit) const {
651  static const int DayZero = TJulianDate::GetJulianDateN(1, 1, 1970);
652  if (TmUnit == tmu1Sec) { return AbsSecs; }
653  struct tm Time;
654  IAssert(IsDef() && GetTmStruct(AbsSecs(), Time));
655  switch (TmUnit) {
656  case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0).GetAbsSecs()/60;
657  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);
658  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);
659  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);
660  case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0).GetAbsSecs()/3600;
661  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);
662  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);
663  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);
664  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);
665  case tmuDay : return TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year) - DayZero;
666  case tmuWeek : return (TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year)-DayZero)/7;
667  case tmuMonth : return 12*(Time.tm_year-70)+Time.tm_mon+1;
668  case tmuYear : return Time.tm_year+1900;
669  default : Fail;
670  }
671  return TUInt::Mx;
672 }
673 
675  const int Hour = GetHourN();
676  if (0 <= Hour && Hour < 6) { return "Night"; }
677  else if (6 <= Hour && Hour < 12) { return "Morning"; }
678  else if (12 <= Hour && Hour < 18) { return "Afternoon"; }
679  else if (18 <= Hour && Hour < 24) { return "Evening"; }
680  return "";
681 }
682 
683 uint TSecTm::GetDSecs(const TSecTm& SecTm1, const TSecTm& SecTm2){
684  IAssert(SecTm1.IsDef()&&SecTm2.IsDef());
685  const time_t Time1= time_t(SecTm1.AbsSecs());
686  const time_t Time2= time_t(SecTm2.AbsSecs());
687  return uint(difftime(Time2, Time1));
688 }
689 
691  TSecTm ZeroWeekTm=GetZeroTm();
692  while (ZeroWeekTm.GetDayOfWeekN()!=TTmInfo::MonN){
693  ZeroWeekTm.AddDays(1);}
694  return ZeroWeekTm;
695 }
696 
698  const time_t TmSec = time(NULL);
699  struct tm LocTm;
700  uint AbsSec = TUInt::Mx;
701  #if defined(GLib_MSN)
702  localtime_s(&LocTm, &TmSec);
703  #elif defined(GLib_BCB)
704  LocTm = *localtime(&TmSec);
705  #else
706  LocTm = *localtime(&TmSec);
707  #endif
708  IAssert(TSecTm::GetTmSec(LocTm, AbsSec));
709  return TSecTm(AbsSec);
710 }
711 
713  int HmsStrLen=HmsStr.Len();
714  // hour
715  TChA ChA; int ChN=0;
716  while ((ChN<HmsStrLen)&&(HmsStr[ChN]!=':')){ChA+=HmsStr[ChN]; ChN++;}
717  TStr HourStr=ChA;
718  // minute
719  ChA.Clr(); ChN++;
720  while ((ChN<HmsStrLen)&&(HmsStr[ChN]!=':')){ChA+=HmsStr[ChN]; ChN++;}
721  TStr MinStr=ChA;
722  // second
723  ChA.Clr(); ChN++;
724  while (ChN<HmsStrLen){ChA+=HmsStr[ChN]; ChN++;}
725  TStr SecStr=ChA;
726  // transform to numbers
727  int HourN=HourStr.GetInt();
728  int MinN=MinStr.GetInt();
729  int SecN=SecStr.GetInt();
730  // construct the time
732  Tm.AddHours(HourN);
733  Tm.AddMins(MinN);
734  Tm.AddSecs(SecN);
735  return Tm;
736 }
737 
739  int MdyStrLen=MdyStr.Len();
740  // month
741  TChA ChA; int ChN=0;
742  while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){
743  ChA+=MdyStr[ChN]; ChN++;}
744  TStr MonthStr=ChA;
745  // day
746  ChA.Clr(); ChN++;
747  while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){
748  ChA+=MdyStr[ChN]; ChN++;}
749  TStr DayStr=ChA;
750  // year
751  ChA.Clr(); ChN++;
752  while (ChN<MdyStrLen){
753  ChA+=MdyStr[ChN]; ChN++;}
754  TStr YearStr=ChA;
755  // transform to numbers
756  int MonthN=MonthStr.GetInt();
757  int DayN=DayStr.GetInt();
758  int YearN=YearStr.GetInt();
759  if (YearN<1000){
760  if (YearN<70){YearN+=2000;} else {YearN+=1900;}}
761  // construct the date
762  return GetDtTm(YearN, MonthN, DayN);
763 }
764 
765 // parse 28/03/03 and 28-MAY-03 formats
767  int DmyStrLen=DmyStr.Len();
768  // day
769  TChA ChA; int ChN=0;
770  while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){
771  ChA+=DmyStr[ChN]; ChN++;}
772  TStr DayStr=ChA;
773  // month
774  ChA.Clr(); ChN++;
775  while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){
776  ChA+=DmyStr[ChN]; ChN++;}
777  TStr MonthStr=ChA;
778  // year
779  ChA.Clr(); ChN++;
780  while (ChN<DmyStrLen){
781  ChA+=DmyStr[ChN]; ChN++;}
782  TStr YearStr=ChA;
783  // transform to numbers
784  int DayN=DayStr.GetInt(-1);
785  int MonthN=MonthStr.GetInt(-1);
786  int YearN=YearStr.GetInt(-1);
787  if (MonthN == -1){
788  MonthN = TTmInfo::GetMonthN(MonthStr.ToCap()); }
789  if ((DayN==-1)||(MonthN==-1)||(YearN==-1)){
790  return TSecTm();
791  } else {
792  if (YearN<1000){
793  if (YearN<70){YearN+=2000;} else {YearN+=1900;}}
794  // construct the date
795  return GetDtTm(YearN, MonthN, DayN);
796  }
797  return TSecTm();
798 }
799 
801  const char& DateSepCh, const char& TimeSepCh){
802  int MdyHmsPmStrLen=MdyHmsPmStr.Len();
803  // month
804  TChA ChA; int ChN=0;
805  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){
806  ChA+=MdyHmsPmStr[ChN]; ChN++;}
807  TStr MonthStr=ChA;
808  // day
809  ChA.Clr(); ChN++;
810  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){
811  ChA+=MdyHmsPmStr[ChN]; ChN++;}
812  TStr DayStr=ChA;
813  // year
814  ChA.Clr(); ChN++;
815  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){
816  ChA+=MdyHmsPmStr[ChN]; ChN++;}
817  TStr YearStr=ChA;
818  // hour
819  ChA.Clr(); ChN++;
820  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){
821  ChA+=MdyHmsPmStr[ChN]; ChN++;}
822  TStr HourStr=ChA;
823  // minute
824  ChA.Clr(); ChN++;
825  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){
826  ChA+=MdyHmsPmStr[ChN]; ChN++;}
827  TStr MinStr=ChA;
828  // second
829  ChA.Clr(); ChN++;
830  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){
831  ChA+=MdyHmsPmStr[ChN]; ChN++;}
832  TStr SecStr=ChA;
833  // AM/PM
834  ChA.Clr(); ChN++;
835  while (ChN<MdyHmsPmStrLen){
836  ChA+=MdyHmsPmStr[ChN]; ChN++;}
837  TStr AmPmStr=ChA;
838  // transform to numbers
839  int MonthN=MonthStr.GetInt();
840  int DayN=DayStr.GetInt();
841  int YearN=YearStr.GetInt();
842  int HourN; int MinN; int SecN;
843  if (HourStr.IsInt()){
844  HourN=HourStr.GetInt();
845  MinN=MinStr.GetInt();
846  SecN=SecStr.GetInt();
847  if (AmPmStr=="AM"){} else if (AmPmStr=="PM"){HourN+=12;} else {Fail;}
848  } else {
849  HourN=0; MinN=0; SecN=0;
850  }
851  // construct the time
852  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
853  Tm.AddHours(HourN);
854  Tm.AddMins(MinN);
855  Tm.AddSecs(SecN);
856  return Tm;
857 }
858 
860  const char& DateSepCh, const char& TimeSepCh){
861  int YmdHmsPmStrLen=YmdHmsPmStr.Len();
862  // year
863  TChA ChA; int ChN=0;
864  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
865  ChA+=YmdHmsPmStr[ChN]; ChN++;}
866  TStr YearStr=ChA;
867  // month
868  ChA.Clr(); ChN++;
869  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
870  ChA+=YmdHmsPmStr[ChN]; ChN++;}
871  TStr MonthStr=ChA;
872  // day
873  ChA.Clr(); ChN++;
874  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=' ')){
875  ChA+=YmdHmsPmStr[ChN]; ChN++;}
876  TStr DayStr=ChA;
877  // hour
878  ChA.Clr(); ChN++;
879  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
880  ChA+=YmdHmsPmStr[ChN]; ChN++;}
881  TStr HourStr=ChA;
882  // minute
883  ChA.Clr(); ChN++;
884  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
885  ChA+=YmdHmsPmStr[ChN]; ChN++;}
886  TStr MinStr=ChA;
887  // second
888  ChA.Clr(); ChN++;
889  while (ChN<YmdHmsPmStrLen){
890  ChA+=YmdHmsPmStr[ChN]; ChN++;}
891  TStr SecStr=ChA;
892  // transform to numbers
893  int MonthN=MonthStr.GetInt();
894  int DayN=DayStr.GetInt();
895  int YearN=YearStr.GetInt();
896  int HourN; int MinN; int SecN;
897  if (HourStr.IsInt()){
898  HourN=HourStr.GetInt();
899  MinN=MinStr.GetInt();
900  SecN=SecStr.GetInt();
901  } else {
902  HourN=0; MinN=0; SecN=0;
903  }
904  // construct the time
905  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
906  Tm.AddHours(HourN);
907  Tm.AddMins(MinN);
908  Tm.AddSecs(SecN);
909  return Tm;
910 }
911 
912 // Parse strings of the form 2006-08-28 14:11:16 or 14:11:16 08/28/2008
913 // Non-numeric characters act as separators (there can be many consecutive separating characters)
914 // Variables give indexes of the date fields
915 TSecTm TSecTm::GetDtTmFromStr(const TChA& YmdHmsPmStr, const int& YearId, const int& MonId,
916  const int& DayId, const int& HourId, const int& MinId, const int& SecId) {
917  TChA Tmp = YmdHmsPmStr;
918  TVec<char *> FldV;
919  // get the sequences of numbers
920  for (char *c = (char *) Tmp.CStr(); *c; c++) {
921  if (TCh::IsNum(*c)) {
922  FldV.Add(c);
923  while (TCh::IsNum(*c)) { c++; }
924  c--;
925  } else { *c = 0; }
926  }
927  const int Y = atoi(FldV[YearId]);
928  const int M = atoi(FldV[MonId]);
929  const int D = atoi(FldV[DayId]);
930  const int H = atoi(FldV[HourId]);
931  const int m = atoi(FldV[MinId]);
932  const int S = atoi(FldV[SecId]);
933  IAssert(Y>0 && M>0 && D>0 && M<13 && D<32);
934  IAssert(H>=0 && H<24 && m>=0 && m<60 && S>=0 && S<60);
935  return TSecTm(Y,M,D,H,m,S);
936 }
937 
938 TSecTm TSecTm::GetDtTm(const int& YearN, const int& MonthN, const int& DayN){
939  uint AbsSecs;
940  TSecTm::GetTmSec(YearN, MonthN, DayN, 0, 0, 0, AbsSecs);
941  return TSecTm(AbsSecs);
942 }
943 
945  int DaySecs=Tm.GetHourN()*3600+Tm.GetMinN()*60+Tm.GetSecN();
946  TSecTm DtTm(Tm.AbsSecs-DaySecs);
947  return DtTm;
948 }
949 
951  return TSecTm(Lx.GetInt());
952 }
953 
954 void TSecTm::SaveTxt(TOLx& Lx) const {
955  IAssert(int(AbsSecs) < TInt::Mx);
956  Lx.PutInt((int)AbsSecs);
957 }
958 
960 // Date-Time
961 TStr TTm::GetStr(const bool& MSecP) const {
962  TChA ChA;
963  ChA+=TInt::GetStr(Year, "%04d"); ChA+='-';
964 // ChA+=GetMonthNm(); ChA+='-';
965  ChA+=TInt::GetStr(Month, "%02d"); ChA+='-';
966  ChA+=TInt::GetStr(Day, "%02d"); ChA+=' ';
967 // ChA+=GetDayOfWeekNm(); ChA+=' ';
968  ChA+=TInt::GetStr(Hour, "%02d"); ChA+=':';
969  ChA+=TInt::GetStr(Min, "%02d"); ChA+=':';
970  ChA+=TInt::GetStr(Sec, "%02d");
971  if (MSecP){ChA+='.'; ChA+=TInt::GetStr(MSec, "%03d");}
972  return ChA;
973 }
974 
976  TChA ChA;
977  ChA+=TInt::GetStr(Year, "%04d");
978  ChA+='-'; ChA+=TInt::GetStr(Month, "%02d");
979  ChA+='-'; ChA+=TInt::GetStr(Day, "%02d");
980  return ChA;
981 }
982 
983 TStr TTm::GetHMSTColonDotStr(const bool& FullP, const bool& MSecP) const {
984  TChA ChA;
985  ChA+=TInt::GetStr(Hour, "%02d");
986  ChA+=':'; ChA+=TInt::GetStr(Min, "%02d");
987  if (FullP||((Sec!=0)||(MSec!=0))){
988  ChA+=':'; ChA+=TInt::GetStr(Sec, "%02d");
989  if ((MSecP)&&(FullP||(MSec!=0))){
990  ChA+='.'; ChA+=TInt::GetStr(MSec, "%d");
991  }
992  }
993  return ChA;
994 }
995 
997  TChA ChA;
998  ChA+=TInt::GetStr(Year%100, "%02d");
999  ChA+=TInt::GetStr(Month, "%02d");
1000  ChA+=TInt::GetStr(Day, "%02d");
1001  ChA+=TInt::GetStr(Hour, "%02d");
1002  ChA+=TInt::GetStr(Min, "%02d");
1003  ChA+=TInt::GetStr(Sec, "%02d");
1004  ChA+=TInt::GetStr(MSec, "%03d");
1005  return ChA;
1006 }
1007 
1008 
1009 void TTm::AddTime(const int& Hours,
1010  const int& Mins, const int& Secs, const int& MSecs){
1011  uint64 TmMSecs=TTm::GetMSecsFromTm(*this);
1012  TmMSecs+=(uint64(Hours)*uint64(3600)*uint64(1000));
1013  TmMSecs+=(uint64(Mins)*uint64(60)*uint64(1000));
1014  TmMSecs+=(uint64(Secs)*uint64(1000));
1015  TmMSecs+=uint64(MSecs);
1016  *this=GetTmFromMSecs(TmMSecs);
1017 }
1018 
1019 void TTm::SubTime(const int& Hours,
1020  const int& Mins, const int& Secs, const int& MSecs){
1021  uint64 TmMSecs=TTm::GetMSecsFromTm(*this);
1022  TmMSecs-=(uint64(Hours)*uint64(3600)*uint64(1000));
1023  TmMSecs-=(uint64(Mins)*uint64(60)*uint64(1000));
1024  TmMSecs-=(uint64(Secs)*uint64(1000));
1025  TmMSecs-=(uint64(MSecs));
1026  *this=GetTmFromMSecs(TmMSecs);
1027 }
1028 
1030  return TSysTm::GetCurUniTm();
1031 }
1032 
1034  static TTm LastUniqueTm=TSysTm::GetCurUniTm();
1035  TTm CurUniqueTm=TSysTm::GetCurUniTm();
1036  if (CurUniqueTm<LastUniqueTm){CurUniqueTm=LastUniqueTm;}
1037  if (CurUniqueTm==LastUniqueTm){CurUniqueTm.AddTime(0, 0, 0, 1);}
1038  LastUniqueTm=CurUniqueTm;
1039  return CurUniqueTm;
1040 }
1041 
1042 TTm TTm::GetUniqueCurUniTm(const int& UniqueSpaces, const int& UniqueSpaceN){
1043  static uint64 LastMUniqueTmMSecs=TSysTm::GetCurUniMSecs();
1044  // uniqueness-space-parameters range-check
1045  Assert(UniqueSpaces>=1&&UniqueSpaceN>=0&&UniqueSpaceN<UniqueSpaces);
1046  // get current time
1047  uint64 CurUniqueTmMSecs=TSysTm::GetCurUniMSecs();
1048  if (CurUniqueTmMSecs<LastMUniqueTmMSecs){CurUniqueTmMSecs=LastMUniqueTmMSecs;}
1049  // normalize to uniqueness-space-grid
1050  CurUniqueTmMSecs-=CurUniqueTmMSecs%UniqueSpaces; CurUniqueTmMSecs+=UniqueSpaceN;
1051  // get next free unique-time
1052  if (CurUniqueTmMSecs<=LastMUniqueTmMSecs){
1053  CurUniqueTmMSecs+=UniqueSpaces;
1054  }
1055  // update last-time
1056  LastMUniqueTmMSecs=CurUniqueTmMSecs;
1057  return GetTmFromMSecs(CurUniqueTmMSecs);
1058 }
1059 
1061  return TSysTm::GetCurLocTm();
1062 }
1063 
1065  return TSysTm::GetCurUniMSecs();
1066 }
1067 
1069  return TSysTm::GetCurLocMSecs();
1070 }
1071 
1073  return TSysTm::GetMSecsFromTm(Tm);
1074 }
1075 
1077  return TSysTm::GetTmFromMSecs(MSecs);
1078 }
1079 
1081  return TSysTm::GetMSecsFromOsStart();
1082 }
1083 
1085  return TSysTm::GetPerfTimerFq();
1086 }
1087 
1089  return TSysTm::GetPerfTimerTicks();
1090 }
1091 
1092 void TTm::GetDiff(const TTm& Tm1, const TTm& Tm2, int& Days,
1093  int& Hours, int& Mins, int& Secs, int& MSecs) {
1094 
1095  const uint64 DiffMSecs = TTm::GetDiffMSecs(Tm1, Tm2);
1096  const uint64 DiffSecs = DiffMSecs / 1000;
1097  const uint64 DiffMins = DiffSecs / 60;
1098  const uint64 DiffHours = DiffMins / 60;
1099 
1100  MSecs = int(DiffMSecs % 1000);
1101  Secs = int(DiffSecs % 60);
1102  Mins = int(DiffMins % 60);
1103  Hours = int(DiffHours % 24);
1104  Days = int((int)DiffHours / 24);
1105 }
1106 
1107 uint64 TTm::GetDiffMSecs(const TTm& Tm1, const TTm& Tm2){
1108  uint64 Tm1MSecs=GetMSecsFromTm(Tm1);
1109  uint64 Tm2MSecs=GetMSecsFromTm(Tm2);
1110  if (Tm1MSecs>Tm2MSecs){
1111  return Tm1MSecs-Tm2MSecs;
1112  } else {
1113  return Tm2MSecs-Tm1MSecs;
1114  }
1115 }
1116 
1118  return TSysTm::GetLocTmFromUniTm(Tm);
1119 }
1120 
1122  return TSysTm::GetUniTmFromLocTm(Tm);
1123 }
1124 
1126  const char TimeSepCh, const char MSecSepCh){
1127  int TimeStrLen=TimeStr.Len();
1128  // year
1129  TChA ChA; int ChN=0;
1130  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
1131  ChA+=TimeStr[ChN]; ChN++;}
1132  TStr HourStr=ChA;
1133  // minute
1134  ChA.Clr(); ChN++;
1135  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
1136  ChA+=TimeStr[ChN]; ChN++;}
1137  TStr MinStr=ChA;
1138  // second
1139  ChA.Clr(); ChN++;
1140  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=MSecSepCh)){
1141  ChA+=TimeStr[ChN]; ChN++;}
1142  TStr SecStr=ChA;
1143  // mili-second
1144  ChA.Clr(); ChN++;
1145  while (ChN<TimeStrLen){
1146  ChA+=TimeStr[ChN]; ChN++;}
1147  TStr MSecStr=ChA;
1148  // transform to numbers
1149  int HourN=HourStr.GetInt(0);
1150  int MinN=MinStr.GetInt(0);
1151  int SecN=SecStr.GetInt(0);
1152  int MSecN=MSecStr.GetInt(0);
1153  // construct time
1154  TTm Tm(-1, -1, -1, -1, HourN, MinN, SecN, MSecN);
1155  // return time
1156  return Tm;
1157 }
1158 
1160  const char DateSepCh, const char TimeSepCh, const char MSecSepCh,
1161  const char DateTimeSepCh){
1162  int DateTimeStrLen=DateTimeStr.Len();
1163  // year
1164  TChA ChA; int ChN=0;
1165  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateSepCh)){
1166  ChA+=DateTimeStr[ChN]; ChN++;}
1167  TStr YearStr=ChA;
1168  // month
1169  ChA.Clr(); ChN++;
1170  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateSepCh)){
1171  ChA+=DateTimeStr[ChN]; ChN++;}
1172  TStr MonthStr=ChA;
1173  // day
1174  ChA.Clr(); ChN++;
1175  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateTimeSepCh)){
1176  ChA+=DateTimeStr[ChN]; ChN++;}
1177  TStr DayStr=ChA;
1178  // hour
1179  ChA.Clr(); ChN++;
1180  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=TimeSepCh)){
1181  ChA+=DateTimeStr[ChN]; ChN++;}
1182  TStr HourStr=ChA;
1183  // minute
1184  ChA.Clr(); ChN++;
1185  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=TimeSepCh)){
1186  ChA+=DateTimeStr[ChN]; ChN++;}
1187  TStr MinStr=ChA;
1188  // second
1189  ChA.Clr(); ChN++;
1190  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=MSecSepCh)){
1191  ChA+=DateTimeStr[ChN]; ChN++;}
1192  TStr SecStr=ChA;
1193  // mili-second
1194  ChA.Clr(); ChN++;
1195  while (ChN<DateTimeStrLen){
1196  ChA+=DateTimeStr[ChN]; ChN++;}
1197  TStr MSecStr=ChA;
1198  // transform to numbers
1199  int YearN=YearStr.GetInt(-1);
1200  int MonthN=MonthStr.GetInt(-1);
1201  int DayN=DayStr.GetInt(-1);
1202  int HourN=HourStr.GetInt(0);
1203  int MinN=MinStr.GetInt(0);
1204  int SecN=SecStr.GetInt(0);
1205  int MSecN=MSecStr.GetInt(0);
1206  // construct time
1207  TTm Tm;
1208  if ((YearN!=-1)&&(MonthN!=-1)&&(DayN!=-1)){
1209  Tm=TTm(YearN, MonthN, DayN, -1, HourN, MinN, SecN, MSecN);
1210  }
1211  // return time
1212  return Tm;
1213 }
1214 
1216  // normalize
1217  TChA IdChA=IdStr;
1218  if (IdChA.Len()==14){
1219  IdChA.Ins(0, "0");}
1220  // check
1221  IAssert(IdChA.Len()==15);
1222  for (int ChN=0; ChN<IdChA.Len(); ChN++){
1223  IAssert(TCh::IsNum(IdChA[ChN]));}
1224  // extract parts
1225  int YearN=2000+(TStr(IdChA[0])+TStr(IdChA[1])).GetInt();
1226  int MonthN=(TStr(IdChA[2])+TStr(IdChA[3])).GetInt();
1227  int DayN=(TStr(IdChA[4])+TStr(IdChA[5])).GetInt();
1228  int HourN=(TStr(IdChA[6])+TStr(IdChA[7])).GetInt();
1229  int MinN=(TStr(IdChA[8])+TStr(IdChA[9])).GetInt();
1230  int SecN=(TStr(IdChA[10])+TStr(IdChA[11])).GetInt();
1231  int MSecN=(TStr(IdChA[12])+TStr(IdChA[13])+TStr(IdChA[14])).GetInt();
1232  TTm Tm=TTm(YearN, MonthN, DayN, -1, HourN, MinN, SecN, MSecN);
1233  return Tm;
1234 }
1235 
1236 uint TTm::GetDateTimeInt(const int& Year, const int& Month,
1237  const int& Day, const int& Hour, const int& Min, const int& Sec) {
1238 
1239  return TSecTm(Year, Month, Day, Hour, Min, Sec).GetAbsSecs();
1240 }
1241 
1243  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay()) : 0;
1244 }
1245 
1247  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear(), Tm.GetMonth()) : 0;
1248 }
1249 
1251  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear()) : 0;
1252 }
1253 
1255  return Tm.IsDef() ?
1256  GetDateTimeInt(Tm.GetYear(), Tm.GetMonth(),
1257  Tm.GetDay(), Tm.GetHour(), Tm.GetMin(), Tm.GetSec()) : 0;
1258 }
1259 
1260 TTm TTm::GetTmFromDateTimeInt(const uint& DateTimeInt) {
1261  if (DateTimeInt == 0) { return TTm(); }
1262  return TTm(TSecTm(DateTimeInt));
1263 }
1264 
1266  if (DateTimeInt == 0) { return TSecTm(); }
1267  return TSecTm(DateTimeInt);
1268 }
1269 
1271 // Time-Profiler - poor-man's profiler
1272 int TTmProfiler::AddTimer(const TStr& TimerNm) {
1273  MxNmLen = TInt::GetMx(MxNmLen, TimerNm.Len());
1274  return TimerH.AddKey(TimerNm);
1275 }
1276 
1278  int TimerId = GetTimerIdFFirst();
1279  while (GetTimerIdFNext(TimerId)) {
1280  ResetTimer(TimerId);
1281  }
1282 }
1283 
1285  double Sum = 0.0;
1286  int TimerId = GetTimerIdFFirst();
1287  while (GetTimerIdFNext(TimerId)) {
1288  Sum += GetTimerSec(TimerId);
1289  }
1290  return Sum;
1291 }
1292 
1293 double TTmProfiler::GetTimerSec(const int& TimerId) const {
1294  return TimerH[TimerId].GetSec();
1295 }
1296 
1297 void TTmProfiler::PrintReport(const TStr& ProfileNm) const {
1298  const double TimerSumSec = GetTimerSumSec();
1299  printf("-- %s --\n", ProfileNm.CStr());
1300  printf("Sum: (%.2f sec):\n", TimerSumSec);
1301  int TimerId = GetTimerIdFFirst();
1302  while (GetTimerIdFNext(TimerId)) {
1303  // get timer name
1304  TStr TimerNm = GetTimerNm(TimerId);
1305  TimerNm = TStr::GetSpaceStr(TimerNm.Len() - MxNmLen) + TimerNm;
1306  // get timer time and precentage
1307  if (TimerSumSec > 0.0) {
1308  const double TimerSec = GetTimerSec(TimerId);
1309  const double TimerPerc = TimerSec / TimerSumSec * 100.0;
1310  printf(" %s: %.2fs [%.2f%%]\n", TimerNm.CStr(), TimerSec, TimerPerc);
1311  } else {
1312  printf(" %s: -\n", TimerNm.CStr());
1313  }
1314  }
1315  printf("--\n");
1316 }
#define IAssert(Cond)
Definition: bd.h:262
double GetTimerSec(const int &TimerId) const
Definition: tm.cpp:1293
void GetComps(int &Year, int &Month, int &Day, int &Hour, int &Min, int &Sec) const
Definition: tm.cpp:614
int GetInt() const
Definition: dt.h:578
int GetMin() const
Definition: tm.h:282
static TStrV UsMonthNmV
Definition: tm.h:24
TStr GetYmdTmStr2() const
Definition: tm.cpp:514
static TStrV SiDayOfWeekNmV
Definition: tm.h:27
TInt MSec
Definition: tm.h:216
bool GetTimerIdFNext(int &TimerId) const
Definition: tm.h:414
int GetMinN() const
Definition: tm.cpp:602
TStr GetStr() const
Definition: dt.h:1197
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:915
static void GetCalendarDate(int jdn, int &dd, int &mm, int &yy)
Definition: tm.cpp:327
TSecTm & AddDays(const int &Days)
Definition: tm.h:168
static TSecTm GetDtTmFromYmdHmsStr(const TStr &YmdHmsPmStr, const char &DateSepCh='-', const char &TimeSepCh=':')
Definition: tm.cpp:859
int Len() const
Definition: dt.h:487
static uint64 GetCurLocMSecs()
Definition: tm.cpp:1068
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:1242
void Ins(const int &BChN, const char *CStr)
Definition: dt.cpp:407
double GetTimerSumSec() const
Definition: tm.cpp:1284
int GetMonth() const
Definition: tm.h:276
static bool IsNum(const char &Ch)
Definition: dt.h:1064
static void GetDiff(const TTm &Tm1, const TTm &Tm2, int &Days, int &Hours, int &Mins, int &Secs, int &MSecs)
Definition: tm.cpp:1092
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:560
bool IsDef() const
Definition: tm.h:123
Definition: tm.h:12
static const uint Mx
Definition: dt.h:1244
TStr GetYMDDashStr() const
Definition: tm.cpp:975
static TTm GetUniTmFromLocTm(const TTm &Tm)
Definition: tm.cpp:1121
static TSecTm GetDtTmFromHmsStr(const TStr &HmsStr)
Definition: tm.cpp:712
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:1182
static uint64 GetCurUniMSecs()
Definition: tm.cpp:1064
void ResetAll()
Definition: tm.cpp:1277
static const int Mx
Definition: dt.h:1139
#define Fail
Definition: bd.h:238
int GetDayOfWeekN() const
Definition: tm.cpp:584
static PXmlTok New()
Definition: xml.h:212
void Clr()
Definition: dt.h:258
TInt Day
Definition: tm.h:215
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
Definition: tm.h:14
TSecTm & AddMins(const int &Mins)
Definition: tm.h:160
static int GetTmUnitSecs(const TTmUnit &TmUnit)
Definition: tm.cpp:85
static TTm GetCurUniTm()
Definition: tm.cpp:1029
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:1254
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:650
void SaveTxt(TOLx &Lx) const
Definition: tm.cpp:954
Definition: tm.h:13
static const int OctN
Definition: tm.h:57
TStr GetTmMinStr() const
Definition: tm.cpp:530
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:1236
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.cpp:1107
static TTm GetTmFromDateTimeInt(const uint &DateTimeInt)
Definition: tm.cpp:1260
static TTm GetTmFromWebLogDateTimeStr(const TStr &DateTimeStr, const char DateSepCh='-', const char TimeSepCh=':', const char MSecSepCh='.', const char DateTimeSepCh=' ')
Definition: tm.cpp:1159
TInt Sec
Definition: tm.h:216
TStr & ToCap()
Definition: dt.cpp:764
TStr GetDtTmSortFNmStr() const
Definition: tm.cpp:550
int GetHour() const
Definition: tm.h:281
int GetMonthN() const
Definition: tm.cpp:566
TInt Min
Definition: tm.h:216
static TSecTm GetDtTmFromDmyStr(const TStr &DmyStr)
Definition: tm.cpp:766
TStr GetIdStr() const
Definition: tm.cpp:996
Definition: tm.h:12
Definition: tm.h:12
static TSecTm GetSecTmFromDateTimeInt(const uint &DateTimeInt)
Definition: tm.cpp:1265
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:738
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:275
int AddTimer(const TStr &TimerNm)
Definition: tm.cpp:1272
static uint GetYearIntFromTm(const TTm &Tm)
Definition: tm.cpp:1250
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:216
static TTm GetTmFromIdStr(const TStr &IdStr)
Definition: tm.cpp:1215
char * CStr()
Definition: dt.h:255
static const int MayN
Definition: tm.h:55
TTm()
Definition: tm.h:218
TInt Month
Definition: tm.h:215
void PrintReport(const TStr &ProfileNm="") const
Definition: tm.cpp:1297
unsigned long long uint64
Definition: bd.h:38
TLoc
Definition: bd.h:63
int GetDay() const
Definition: tm.h:278
int GetTimerIdFFirst() const
Definition: tm.h:413
Definition: lx.h:129
uint GetAbsSecs() const
Definition: tm.h:150
int GetSecN() const
Definition: tm.cpp:608
#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:596
bool IsDef() const
Definition: tm.h:265
void AddArg(const TStr &ArgNm, const bool &ArgVal)
Definition: xml.h:252
int GetDayN() const
Definition: tm.cpp:578
int GetIntArgVal(const TStr &ArgNm, const int &DfVal=0) const
Definition: xml.cpp:1109
static uint GetMSecsFromOsStart()
Definition: tm.cpp:1080
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:1088
static TTm GetCurLocTm()
Definition: tm.cpp:1060
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:590
TInt Year
Definition: tm.h:215
Definition: tm.h:213
TSecTm & AddSecs(const int &Secs)
Definition: tm.h:156
Definition: dt.h:201
#define EAssert(Cond)
Definition: bd.h:280
Definition: dt.h:1239
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:690
Definition: tm.h:81
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:938
static TStrV SiMonthNmV
Definition: tm.h:25
int AddKey(const TKey &Key)
Definition: hash.h:373
TInt MxNmLen
Definition: tm.h:402
Definition: tm.h:12
static TStr GetTmZoneDiffStr(const TStr &TmZoneStr)
Definition: tm.cpp:131
static TSecTm LoadTxt(TILx &Lx)
Definition: tm.cpp:950
TStr GetTimerNm(const int &TimerId) const
Definition: tm.h:411
static TStr GetTmUnitStr(const TTmUnit &TmUnit)
Definition: tm.cpp:108
int GetSec() const
Definition: tm.h:283
TStr GetDtTmSortStr() const
Definition: tm.cpp:540
static uint GetMonthIntFromTm(const TTm &Tm)
Definition: tm.cpp:1246
TStr GetMonthNm(const TLoc &Loc=lUs) const
Definition: tm.cpp:572
Definition: dt.h:412
static TTm GetUniqueCurUniTm()
Definition: tm.cpp:1033
static TTm GetTmFromWebLogTimeStr(const TStr &TimeStr, const char TimeSepCh=':', const char MSecSepCh='.')
Definition: tm.cpp:1125
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:1552
static const int AugN
Definition: tm.h:56
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
void ResetTimer(const TStr &TimerNm)
Definition: tm.h:423
TStr GetHMSTColonDotStr(const bool &FullP=false, const bool &MSecP=true) const
Definition: tm.cpp:983
static TSecTm GetCurTm()
Definition: tm.cpp:697
TStr GetTmStr() const
Definition: tm.cpp:520
static TTm GetTmFromMSecs(const uint64 &MSecs)
Definition: tm.cpp:1076
Definition: bd.h:63
static uint GetDSecs(const TSecTm &SecTm1, const TSecTm &SecTm2)
Definition: tm.cpp:683
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403
uint Val
Definition: dt.h:1241
void AddTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1009
Definition: tm.h:12
static TSecTm GetDtTmFromMdyHmsPmStr(const TStr &MdyHmsPmStr, const char &DateSepCh='/', const char &TimeSepCh=':')
Definition: tm.cpp:800
Definition: tm.h:13
static int GetDayOfWeekN(const TStr &DayOfWeekNm, const TLoc &Loc=lUs)
Definition: tm.cpp:60
TStr GetDayPart() const
Definition: tm.cpp:674
static const int SunN
Definition: tm.h:47
static uint64 GetPerfTimerFq()
Definition: tm.cpp:1084
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:602
static const int MonN
Definition: tm.h:47
TStr GetStr(const bool &MSecP=true) const
Definition: tm.cpp:961
TSecTm & AddHours(const int &Hours)
Definition: tm.h:164
void SubTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1019
static uint64 GetMSecsFromTm(const TTm &Tm)
Definition: tm.cpp:1072
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:1117
Definition: tm.h:14
TSecTm Round(const TTmUnit &TmUnit) const
Definition: tm.cpp:625
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:187