libtime++: Date and time calculation
libtime++.h
Go to the documentation of this file.
1 /* this is <libtime++.h>
2  * ----------------------------------------------------------------------------
3  *
4  * Copyright (c) by Thomas Forbriger (IfG Stuttgart)
5  *
6  * interface of class libtime++
7  *
8  * ----
9  * libtime is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  * ----
23  *
24  * REVISIONS and CHANGES
25  * 09/08/2000 V1.0 Thomas Forbriger
26  * 10/08/2000 V1.1 started with operators
27  * 06/09/2000 V1.2 finished operators and rearranged base class
28  * constructors
29  * 12/09/2000 V1.3 added absolute - absolute --> relative
30  * implemented non-member multiplication
31  * 22/12/2000 V1.4 changed namespace time to libtime (resolved conflict
32  * with system time library)
33  * 22/12/2003 V1.5 added function now()
34  * 22/12/2003 V1.6 whooo - was a bit sloppy - corrected some errors
35  * 27/12/2003 V1.7 added member function of TAbsoluteTime to
36  * set doy explicitely
37  * 13/01/2004 V1.8 added constructor from double for TRelativeTime
38  * 02/02/2004 V1.9 constructor from double for TRelativeTime
39  * was highly ambiguous
40  * move conversion to doubel2time() function
41  * 15/07/2005 V1.10 print usage information
42  * 28/04/2006 V1.11 - we need a forward declaration for TRelativeTime
43  * - provide virtual destructor for Exception class
44  * 17/12/2007 V1.12 replace long int by typedef timeint
45  * 25/11/2008 V1.13 added function utc()
46  * 12/12/2008 V1.14 added hierarchical time strings
47  * 20/02/2012 V1.15
48  * - implement new classes for shorter time intervals
49  * - use const char*
50  * 16/12/2012 V1.16 implemented strftime(3) formatted string for
51  * TAbsoluteTime
52  *
53  * ============================================================================
54  */
55 
56 #ifndef TF_LIBTIME_H_
57 #define TF_LIBTIME_H_ "version V1.16"
58 
59 #include <string>
60 #include "libtime.h"
61 
62 using std::string;
63 
64 namespace libtime {
65 
101 
111 /*S*/
112 // member functions common to both flavours of time
113  public:
114  std::string timestring() const;
115  timeint hour() const;
116  timeint minute() const;
117  timeint second() const;
118  timeint milsec() const;
119  timeint micsec() const;
120  double float_second() const;
121 
122  operator time_kernel::time_Ts() const;
123  operator std::string() const;
124 /*E*/
125 // make constructors and member protected
126  protected:
127  TBaseClassTime(const std::string &Itimestring);
128  TBaseClassTime(const char *Itimestring);
129  TBaseClassTime(const time_kernel::time_Ts &Itime_Ts);
130  TBaseClassTime(const timeint &year, const timeint &doy,
131  const timeint &hour=0,
132  const timeint &minute=0, const timeint &second=0,
133  const timeint &milsec=0, const timeint &micsec=0);
134  void string_read(const std::string &timestring);
135  void char_read(const char *timestring);
136  // well, there is no need to make norm accessible to public, as we will
137  // always norm the structure ourselfs
138  void norm();
139  // here we hold the current values
140  time_kernel::time_Ts Mtime_Ts;
141 };
142 
143 /*S*/
144 
146 class TRelativeTime;
147 
150  friend class TRelativeTime;
151  public:
152  TAbsoluteTime(const std::string &Itimestring);
153  TAbsoluteTime(const char *Itimestring);
154  TAbsoluteTime(const time_kernel::time_Ts &Itime_Ts);
155  TAbsoluteTime(const timeint &year=2000, const timeint &month=1,
156  const timeint &day=1, const timeint &hour=0,
157  const timeint &minute=0, const timeint &second=0,
158  const timeint &milsec=0, const timeint &micsec=0);
159 
160  void setdoy(const timeint &doy);
161  void setdoy(const timeint &day, const timeint &month);
162  void setdate(const timeint &day, const timeint &month);
163  void getdate(timeint &day, timeint &month) const;
164  bool isleapyear() const;
165 
166  timeint year() const;
167  timeint doy() const;
168  timeint month() const;
169  timeint day() const;
170  std::string hierarchicalstring() const;
171 
172  bool operator==(const TAbsoluteTime &A) const;
173  bool operator!=(const TAbsoluteTime &A) const;
174  bool operator<=(const TAbsoluteTime &A) const;
175  bool operator>=(const TAbsoluteTime &A) const;
176  bool operator< (const TAbsoluteTime &A) const;
177  bool operator> (const TAbsoluteTime &A) const;
178 
181  TAbsoluteTime operator+ (const TRelativeTime &A) const;
182  TAbsoluteTime operator- (const TRelativeTime &A) const;
183  TRelativeTime operator- (const TAbsoluteTime &A) const;
184 
185  TAbsoluteTime &operator= (const time_kernel::time_Ts &A);
186  TAbsoluteTime &operator= (const std::string &timestring);
187  TAbsoluteTime &operator= (const char *timestring);
188 
190  std::string timestring(const std::string& format) const;
191 };
192 
202  friend class TAbsoluteTime;
203  public:
204  TRelativeTime(const std::string &Itimestring);
205  TRelativeTime(const char *Itimestring);
206  TRelativeTime(const time_kernel::time_Ts &Itime_Ts);
207  TRelativeTime(const int &days=0, const int &hour=0,
208  const int &minute=0, const int &second=0,
209  const int &milsec=0, const int &micsec=0);
210 
211  timeint days() const;
212  std::string hierarchicalstring() const;
213  void nfit(const TRelativeTime &delta, timeint &n, TRelativeTime &full)
214  const;
215  void div(const timeint &n, TRelativeTime &frac, timeint &rest)
216  const;
217 
218  bool operator==(const TRelativeTime &A) const;
219  bool operator!=(const TRelativeTime &A) const;
220  bool operator<=(const TRelativeTime &A) const;
221  bool operator>=(const TRelativeTime &A) const;
222  bool operator< (const TRelativeTime &A) const;
223  bool operator> (const TRelativeTime &A) const;
224 
227  TRelativeTime operator+ (const TRelativeTime &A) const;
228  TRelativeTime operator- (const TRelativeTime &A) const;
229 
232 
233  TRelativeTime &operator*=(const timeint &n);
234  TRelativeTime &operator/=(const timeint &n);
235  TRelativeTime &operator%=(const timeint &n);
236 
237  TRelativeTime operator* (const timeint &n) const;
238  TRelativeTime operator/ (const timeint &n) const;
239  TRelativeTime operator% (const timeint &n) const;
240 
241  timeint operator/ (const TRelativeTime &A) const;
242  TRelativeTime operator% (const TRelativeTime &A) const;
243 
244  TRelativeTime &operator= (const time_kernel::time_Ts &A);
245  TRelativeTime &operator= (const std::string &timestring);
246  TRelativeTime &operator= (const char *timestring);
247 };
248 
250 
251 /*E*/
252 
253 /*
254  * Here we go for inline functions
255  * ===============================
256  */
257 
258 /*
259  * TBaseClassTime
260  * --------------
261  */
262 inline TBaseClassTime::TBaseClassTime(const std::string &Itimestring)
263  { string_read(Itimestring); }
264 inline TBaseClassTime::TBaseClassTime(const char *Itimestring)
265  { char_read(Itimestring); }
266 
267 inline std::string TBaseClassTime::timestring() const
268  { return(std::string(time_kernel::time_sprint(Mtime_Ts))); }
269 
270 inline void TBaseClassTime::norm()
272 
273 inline TBaseClassTime::TBaseClassTime(const time_kernel::time_Ts &Itime_Ts):
274  Mtime_Ts(Itime_Ts) { }
275 
277  const timeint &doy, const timeint &hour,
278  const timeint &minute, const timeint &second,
279  const timeint &milsec, const timeint &micsec)
280 {
281  Mtime_Ts.year =year;
282  Mtime_Ts.doy =doy;
283  Mtime_Ts.hour =hour;
284  Mtime_Ts.minute =minute;
285  Mtime_Ts.second =second;
286  Mtime_Ts.milsec =milsec;
287  Mtime_Ts.micsec =micsec;
288 }
289 
290 inline timeint TBaseClassTime::hour() const { return(Mtime_Ts.hour); }
291 inline timeint TBaseClassTime::minute() const { return(Mtime_Ts.minute); }
292 inline timeint TBaseClassTime::second() const { return(Mtime_Ts.second); }
293 inline timeint TBaseClassTime::milsec() const { return(Mtime_Ts.milsec); }
294 inline timeint TBaseClassTime::micsec() const { return(Mtime_Ts.micsec); }
295 inline double TBaseClassTime::float_second() const
296  { return(Mtime_Ts.second+1.e-3*Mtime_Ts.milsec+1.e-6*Mtime_Ts.micsec); }
297 
298 inline TBaseClassTime::operator time_kernel::time_Ts() const
299  { return(Mtime_Ts); }
300 inline TBaseClassTime::operator std::string() const { return(timestring()); }
301 
302 /*
303  * TAbsoluteTime
304  * -------------
305  */
306 inline TAbsoluteTime::TAbsoluteTime(const std::string &Itimestring):
308 inline TAbsoluteTime::TAbsoluteTime(const char *Itimestring):
310 
311 inline TAbsoluteTime::TAbsoluteTime(const time_kernel::time_Ts &Itime_Ts):
312  TBaseClassTime(Itime_Ts)
314 
316  const timeint &month, const timeint &day, const timeint &hour,
317  const timeint &minute, const timeint &second,
318  const timeint &milsec, const timeint &micsec):
319  TBaseClassTime(year, 1, hour, minute, second, milsec, micsec)
321 
322 inline void TAbsoluteTime::setdoy(const timeint &doy)
323  { Mtime_Ts.doy=doy; this->norm(); }
324 
325 inline void TAbsoluteTime::setdoy(const timeint &day, const timeint &month)
327 
328 inline void TAbsoluteTime::setdate(const timeint &day, const timeint &month)
330 
331 inline void TAbsoluteTime::getdate(timeint &day, timeint &month) const
333 
334 inline bool TAbsoluteTime::isleapyear() const
336 
337 inline timeint TAbsoluteTime::year() const { return(Mtime_Ts.year); }
338 inline timeint TAbsoluteTime::doy() const { return(Mtime_Ts.doy); }
340  { timeint day, month; getdate(day, month); return(month); }
342  { timeint day, month; getdate(day, month); return(day); }
343 
344 inline bool TAbsoluteTime::operator==(const TAbsoluteTime &A) const
345  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)==0); }
346 inline bool TAbsoluteTime::operator!=(const TAbsoluteTime &A) const
347  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)!=0); }
348 inline bool TAbsoluteTime::operator<=(const TAbsoluteTime &A) const
349  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)<=0); }
350 inline bool TAbsoluteTime::operator>=(const TAbsoluteTime &A) const
351  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)>=0); }
352 inline bool TAbsoluteTime::operator< (const TAbsoluteTime &A) const
353  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)< 0); }
354 inline bool TAbsoluteTime::operator> (const TAbsoluteTime &A) const
355  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)> 0); }
356 
358 {
361  return(*this);
362 }
364 {
367  return(*this);
368 }
369 
371  { TAbsoluteTime B(Mtime_Ts); return(B+=A); }
373  { TAbsoluteTime B(Mtime_Ts); return(B-=A); }
375 {
376  TRelativeTime B;
378  return(B);
379 }
380 
381 inline TAbsoluteTime &TAbsoluteTime::operator= (const time_kernel::time_Ts &A)
382  { Mtime_Ts=A; time_kernel::time_finish(&Mtime_Ts); return(*this); }
383 inline TAbsoluteTime &TAbsoluteTime::operator= (const std::string &timestring)
384  { string_read(timestring); return(*this); }
385 inline TAbsoluteTime &TAbsoluteTime::operator= (const char *timestring)
386  { char_read(timestring); return(*this); }
387 
388 /*
389  * TRelativeTime
390  * -------------
391  */
392 inline TRelativeTime::TRelativeTime(const string &Itimestring):
393  TBaseClassTime("0/0/" + Itimestring) { }
394 inline TRelativeTime::TRelativeTime(const char *Itimestring):
395  TBaseClassTime("0/0/" + std::string(Itimestring)) { }
396 
397 inline TRelativeTime::TRelativeTime(const time_kernel::time_Ts &Itime_Ts):
398  TBaseClassTime(Itime_Ts)
399  { Mtime_Ts.year=0; norm(); }
400 
401 inline TRelativeTime::TRelativeTime(const int &days,
402  const int &hour,
403  const int &minute, const int &second,
404  const int &milsec, const int &micsec):
405  TBaseClassTime(0, days, hour, minute, second, milsec, micsec)
406  { norm(); }
407 
408 inline timeint TRelativeTime::days() const { return(Mtime_Ts.doy); }
409 
410 inline void TRelativeTime::nfit(const TRelativeTime &delta, timeint &n,
411  TRelativeTime &full) const
412  { time_kernel::time_nfit(Mtime_Ts, delta.Mtime_Ts, &n, &full.Mtime_Ts); }
413 
414 inline void TRelativeTime::div(const timeint &n, TRelativeTime &frac,
415  timeint &rest) const
416  { time_kernel::time_div(Mtime_Ts, &frac.Mtime_Ts, n, &rest); }
417 
418 
419 inline bool TRelativeTime::operator==(const TRelativeTime &A) const
420  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)==0); }
421 inline bool TRelativeTime::operator!=(const TRelativeTime &A) const
422  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)!=0); }
423 inline bool TRelativeTime::operator<=(const TRelativeTime &A) const
424  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)<=0); }
425 inline bool TRelativeTime::operator>=(const TRelativeTime &A) const
426  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)>=0); }
427 inline bool TRelativeTime::operator< (const TRelativeTime &A) const
428  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)< 0); }
429 inline bool TRelativeTime::operator> (const TRelativeTime &A) const
430  { return(time_kernel::time_compare(Mtime_Ts,A.Mtime_Ts)> 0); }
431 
433 {
436  return(*this);
437 }
439 {
442  return(*this);
443 }
444 
446  { TRelativeTime B(Mtime_Ts); return(B+=A); }
448  { TRelativeTime B(Mtime_Ts); return(B-=A); }
449 
451  { TRelativeTime B(Mtime_Ts); return(A+=B); }
453  { TRelativeTime B(Mtime_Ts); return(A-=B); }
454 
456 {
457  time_kernel::time_Ts A(Mtime_Ts);
459  return(*this);
460 }
462 {
463  time_kernel::time_Ts B(Mtime_Ts);
464  timeint rest;
465  time_kernel::time_div(B, &Mtime_Ts, n, &rest);
466  return(*this);
467 }
469 {
470  time_kernel::time_Ts B(Mtime_Ts);
471  timeint rest;
472  time_kernel::time_div(B, &Mtime_Ts, n, &rest);
474  Mtime_Ts.micsec=rest;
476  return(*this);
477 }
478 
480  { TRelativeTime B(Mtime_Ts); return(B*=n); }
482  { TRelativeTime B(Mtime_Ts); return(B/=n); }
484  { TRelativeTime B(Mtime_Ts); return(B%=n); }
485 
486 inline TRelativeTime operator* (const timeint &n, const TRelativeTime &A)
487  { TRelativeTime B(A); return(B*=n); }
488 
490 {
491  timeint n;
492  time_kernel::time_Ts full;
494  return(n);
495 }
497 {
498  timeint n;
499  time_kernel::time_Ts full, rest;
501  time_kernel::time_sub(Mtime_Ts, full, &rest);
502  return(TRelativeTime(rest));
503 }
504 
505 inline TRelativeTime &TRelativeTime::operator= (const time_kernel::time_Ts &A)
506  { Mtime_Ts=A; Mtime_Ts.year=0; norm(); return(*this); }
507 inline TRelativeTime &TRelativeTime::operator= (const std::string &timestring)
508  { string_read("0/0/" + timestring); return(*this); }
509 inline TRelativeTime &TRelativeTime::operator= (const char *timestring)
510  { string_read("0/0/" + std::string(timestring)); return(*this); }
511 
512 /*======================================================================*/
513 /*S*/
514 
515 /*
516  * some functions
517  * --------------
518  */
524 double time2double(const TRelativeTime&);
526 TRelativeTime double2time(const double& seconds);
528 void dump(std::ostream& os, const TBaseClassTime& t);
529 /*E*/
530 
531 /*======================================================================*/
532 /*S*/
533 
537 class Days: public TRelativeTime {
538  public:
539  Days(const timeint &day=1, const timeint &hour=0,
540  const timeint &minute=0, const timeint &second=0,
541  const timeint &milsec=0, const timeint &micsec=0)
542  : TRelativeTime(day, hour, minute, second, milsec, micsec) { }
543  Days(const double &days)
544  : TRelativeTime(double2time(60.*60.*24.*days)) { }
545 }; // class Days
546 
550 class Hours: public TRelativeTime {
551  public:
552  Hours(const timeint &hour=1,
553  const timeint &minute=0, const timeint &second=0,
554  const timeint &milsec=0, const timeint &micsec=0)
556  Hours(const double &hours)
557  : TRelativeTime(double2time(60.*60.*hours)) { }
558 }; // class Hours
559 
563 class Minutes: public TRelativeTime {
564  public:
565  Minutes(const timeint &minute=1, const timeint &second=0,
566  const timeint &milsec=0, const timeint &micsec=0)
567  : TRelativeTime(0, 0, minute, second, milsec, micsec) { }
568  Minutes(const double &minutes)
569  : TRelativeTime(double2time(60.*minutes)) { }
570 }; // class Minutes
571 
575 class Seconds: public TRelativeTime {
576  public:
578  const timeint &milsec=0, const timeint &micsec=0)
579  : TRelativeTime(0, 0, 0, second, milsec, micsec) { }
580  Seconds(const double &seconds)
581  : TRelativeTime(double2time(seconds)) { }
582 }; // class Seconds
583 
588  public:
590  : TRelativeTime(0, 0, 0, 0, milsec, micsec) { }
591  Milliseconds(const double &milliseconds)
592  : TRelativeTime(double2time(1.e-3*milliseconds)) { }
593 }; // class Milliseconds
594 
599  public:
601  : TRelativeTime(0, 0, 0, 0, 0, micsec) { }
602  Microseconds(const double &microseconds)
603  : TRelativeTime(double2time(1.e-6*microseconds)) { }
604 }; // class Microseconds
605 
606 /*E*/
607 
608 /*======================================================================*/
609 /*S*/
610 
612  class TRange {
613  public:
614  TRange(): Mbegin(now()), Mend(now()) { }
615  TRange(const TAbsoluteTime& begin,
616  const TAbsoluteTime& end);
617  TAbsoluteTime begin() const { return(Mbegin); }
618  TAbsoluteTime end() const { return(Mend); }
619  TRelativeTime size() const { return(Mend-Mbegin); }
620  bool includes(const TAbsoluteTime&) const;
621  bool includes(const TRange&) const;
622  bool overlaps(const TRange&) const;
623  TRange largestcommon(const TRange&) const;
624  TRange smallestcommon(const TRange&) const;
625  TRange& delay(const TRelativeTime&);
626  TRange& advance(const TRelativeTime&);
627  TRange delayedby(const TRelativeTime&) const;
628  TRange advancedby(const TRelativeTime&) const;
629  void expand(const TRange&);
630  void shrink(const TRange&);
631  private:
634  }; // class TRange
635 
636 /*E*/
637 
638 /*======================================================================*/
639 // error handling and exception class
640 // ----------------------------------
641 
642 /*S*/
643  struct Warning {
644  public:
645  static bool suppress_normal;
646  static bool suppress_year;
647  static bool suppress_any;
648  }; // class Warning
649 
650  class Exception
651  {
652  public:
654  Exception();
656  Exception(const char* message);
658  Exception(const char* message,
659  const char* condition);
661  Exception(const char* message,
662  const char* file,
663  const int& line,
664  const char* condition);
666  Exception(const char* message,
667  const char* file,
668  const int& line);
670  virtual ~Exception() { }
672  virtual void report() const;
674  static void report_on_construct();
676  static void dont_report_on_construct();
677  protected:
679  void base_report() const;
680  private:
682  static bool Mreport_on_construct;
684  const char* Mmessage;
686  const char* Mfile;
688  const int& Mline;
690  const char* Mcondition;
691  }; // class Exception
692 
693 /*======================================================================*/
694 //
695 // preprocessor macros
696 // ===================
697 
705 #define libtime_Xassert(C,M,E) \
706  if (!(C)) { throw( E ( M , __FILE__, __LINE__, #C )); }
707 
714 #define libtime_assert(C,M) libtime_Xassert( C , M , libtime::Exception )
715 
722 #define libtime_abort(M) \
723  throw( libtime::Exception ( M , __FILE__, __LINE__ ))
724 /*E*/
725 
726 /*======================================================================*/
727 /*S*/
728 
729 /*
730  * some string constants
731  * --------------
732  */
734 extern const char usage_time_format_string[];
735 /*E*/
736 
737 } // namespace libtime
738 #endif // TF_LIBTIME_H_
739 
740 /* ----- END OF libtime++.h ----- */
Exception()
Creates exception with no explaining comments.
Definition: error.cc:49
bool operator<=(const TRelativeTime &A) const
Definition: libtime++.h:423
TAbsoluteTime begin() const
Definition: libtime++.h:617
TRelativeTime & operator%=(const timeint &n)
Definition: libtime++.h:468
TBaseClassTime(const std::string &Itimestring)
Definition: libtime++.h:262
TAbsoluteTime(const std::string &Itimestring)
Definition: libtime++.h:306
integer time_isleapyear(timeint year)
timeint days() const
Definition: libtime++.h:408
const char * Mcondition
pointer to assertion condition text string
Definition: libtime++.h:690
const char * Mmessage
pointer to message string
Definition: libtime++.h:684
time range
Definition: libtime++.h:612
void setdoy(const timeint &doy)
Definition: libtime++.h:322
timeint year() const
Definition: libtime++.h:337
TRelativeTime & operator+=(const TRelativeTime &A)
Definition: libtime++.h:432
void time_div(time_Ts Date1, time_Ts *Pdate2, timeint n, timeint *rest)
Definition: ctime_div.c:36
bool operator>(const TAbsoluteTime &A) const
Definition: libtime++.h:354
TRelativeTime & operator*=(const timeint &n)
Definition: libtime++.h:455
TRelativeTime operator/(const timeint &n) const
Definition: libtime++.h:481
char * time_sprint(time_Ts Date)
Definition: ctime_sprint.c:39
static bool suppress_year
Definition: libtime++.h:646
TAbsoluteTime end() const
Definition: libtime++.h:618
double float_second() const
Definition: libtime++.h:295
double time2double(const TRelativeTime &rtime)
convert relative time to seconds
Definition: convert.cc:59
Seconds(const timeint &second=1, const timeint &milsec=0, const timeint &micsec=0)
Definition: libtime++.h:577
Days(const double &days)
Definition: libtime++.h:543
time_kernel::time_Ts Mtime_Ts
Definition: libtime++.h:140
provide a convenient way to specify time intervals in the order of one hour
Definition: libtime++.h:550
bool isleapyear() const
Definition: libtime++.h:334
provide a convenient way to specify time intervals in the order of one microsecond ...
Definition: libtime++.h:598
TRelativeTime double2time(const double &seconds)
convert seconds to relative time
Definition: convert.cc:42
void nfit(const TRelativeTime &delta, timeint &n, TRelativeTime &full) const
Definition: libtime++.h:410
timeint month() const
Definition: libtime++.h:339
timeint doy() const
Definition: libtime++.h:338
TAbsoluteTime Mend
Definition: libtime++.h:633
TAbsoluteTime utc()
return system time in UTC
Definition: now.cc:58
static bool suppress_any
Definition: libtime++.h:647
Milliseconds(const timeint &milsec=1, const timeint &micsec=0)
Definition: libtime++.h:589
STL namespace.
Minutes(const double &minutes)
Definition: libtime++.h:568
provide a convenient way to specify time intervals in the order of one day
Definition: libtime++.h:537
TAbsoluteTime & operator-=(const TRelativeTime &A)
Definition: libtime++.h:363
TAbsoluteTime & operator=(const time_kernel::time_Ts &A)
Definition: libtime++.h:381
void time_add(time_Ts Date1, time_Ts Date2, time_Ts *Pdate3)
Definition: ctime_add.c:33
TRelativeTime(const std::string &Itimestring)
Definition: libtime++.h:392
timeint day() const
Definition: libtime++.h:341
class to contain relative times
Definition: libtime++.h:201
timeint milsec() const
Definition: libtime++.h:293
TRelativeTime & operator-=(const TRelativeTime &A)
Definition: libtime++.h:438
Minutes(const timeint &minute=1, const timeint &second=0, const timeint &milsec=0, const timeint &micsec=0)
Definition: libtime++.h:565
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:80
bool operator!=(const TAbsoluteTime &A) const
Definition: libtime++.h:346
Microseconds(const double &microseconds)
Definition: libtime++.h:602
Days(const timeint &day=1, const timeint &hour=0, const timeint &minute=0, const timeint &second=0, const timeint &milsec=0, const timeint &micsec=0)
Definition: libtime++.h:539
void dump(std::ostream &os, const TBaseClassTime &t)
dump internal representation of time (for debugging purposes)
Definition: dump.cc:26
virtual ~Exception()
provide explicit virtual destructor
Definition: libtime++.h:670
void time_getdate(timeint *day, timeint *month, time_Ts Date)
Definition: ctime_getdate.c:36
TRange largestcommon(const TRange &) const
find largest range spanned by both
Definition: ranges.cc:68
TAbsoluteTime operator+(const TRelativeTime &A) const
Definition: libtime++.h:370
const char * Mfile
pointer to file name string
Definition: libtime++.h:686
std::string timestring() const
Definition: libtime++.h:267
bool operator>=(const TRelativeTime &A) const
Definition: libtime++.h:425
TRange & advance(const TRelativeTime &)
advance this range by dt
Definition: ranges.cc:94
TRange advancedby(const TRelativeTime &) const
return a range advanced by dt
Definition: ranges.cc:110
const int & Mline
pointer to line number in source file
Definition: libtime++.h:688
Hours(const double &hours)
Definition: libtime++.h:556
TRelativeTime operator%(const timeint &n) const
Definition: libtime++.h:483
provide a convenient way to specify time intervals in the order of one minute
Definition: libtime++.h:563
void time_setdoy(timeint day, timeint month, time_Ts *Pdate)
Definition: ctime_setdoy.c:36
void time_clear(time_Ts *Pdate)
Definition: ctime_clear.c:33
bool operator>=(const TAbsoluteTime &A) const
Definition: libtime++.h:350
void expand(const TRange &)
set to largest range spanned by both
Definition: ranges.cc:118
void div(const timeint &n, TRelativeTime &frac, timeint &rest) const
Definition: libtime++.h:414
TRelativeTime size() const
Definition: libtime++.h:619
TRelativeTime operator-(const TRelativeTime &A) const
Definition: libtime++.h:447
void time_norm(time_Ts *Pdate)
Definition: ctime_norm.c:33
void time_fullyear(timeint *year)
Hours(const timeint &hour=1, const timeint &minute=0, const timeint &second=0, const timeint &milsec=0, const timeint &micsec=0)
Definition: libtime++.h:552
void setdate(const timeint &day, const timeint &month)
Definition: libtime++.h:328
std::string hierarchicalstring() const
bool operator<(const TRelativeTime &A) const
Definition: libtime++.h:427
bool operator!=(const TRelativeTime &A) const
Definition: libtime++.h:421
const char usage_time_format_string[]
print information on time format
Definition: usage.cc:41
Seconds(const double &seconds)
Definition: libtime++.h:580
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:86
void char_read(const char *timestring)
Definition: base_constr.cc:59
TRelativeTime & operator/=(const timeint &n)
Definition: libtime++.h:461
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: libtime++.h:682
static bool suppress_normal
Definition: libtime++.h:645
bool operator<=(const TAbsoluteTime &A) const
Definition: libtime++.h:348
TRelativeTime operator*(const time_kernel::timeint &n, const TRelativeTime &A)
bool overlaps(const TRange &) const
true if other range overlaps this one
Definition: ranges.cc:62
void time_sub(time_Ts Date1, time_Ts Date2, time_Ts *Pdate3)
Definition: ctime_sub.c:33
TAbsoluteTime operator-(const TRelativeTime &A) const
Definition: libtime++.h:372
TRelativeTime operator*(const timeint &n) const
Definition: libtime++.h:479
TRange & delay(const TRelativeTime &)
delay this range by dt
Definition: ranges.cc:86
bool operator==(const TAbsoluteTime &A) const
Definition: libtime++.h:344
integer timeint
Definition: libtime.h:77
#define TIME_ISLEAP
Definition: libtime.h:108
timeint micsec() const
Definition: libtime++.h:294
timeint hour() const
Definition: libtime++.h:290
TAbsoluteTime & operator+=(const TRelativeTime &A)
Definition: libtime++.h:357
void time_nfit(time_Ts Date1, time_Ts Date2, timeint *n, time_Ts *Pfull)
Definition: ctime_nfit.c:36
void getdate(timeint &day, timeint &month) const
Definition: libtime++.h:331
void base_report() const
Screen report.
Definition: error.cc:98
bool operator<(const TAbsoluteTime &A) const
Definition: libtime++.h:352
void time_mul(time_Ts Date1, time_Ts *Pdate2, integer n)
Definition: ctime_mul.c:35
TRelativeTime operator+(const TRelativeTime &A) const
Definition: libtime++.h:445
timeint second() const
Definition: libtime++.h:292
void shrink(const TRange &)
set to smallest range common to both
Definition: ranges.cc:125
provide a convenient way to specify time intervals in the order of one millisecond ...
Definition: libtime++.h:587
bool includes(const TAbsoluteTime &) const
true if date is within range
Definition: ranges.cc:50
TRange delayedby(const TRelativeTime &) const
return a range delayed by dt
Definition: ranges.cc:102
bool operator==(const TRelativeTime &A) const
Definition: libtime++.h:419
TAbsoluteTime now()
return system time
Definition: now.cc:44
void string_read(const std::string &timestring)
Definition: base_constr.cc:47
provide a convenient way to specify time intervals in the order of one second
Definition: libtime++.h:575
void time_finish(time_Ts *Pdate)
Definition: ctime_finish.c:33
class to contain absolute times
Definition: libtime++.h:149
TAbsoluteTime Mbegin
Definition: libtime++.h:632
timeint minute() const
Definition: libtime++.h:291
Microseconds(const timeint &micsec=1)
Definition: libtime++.h:600
virtual void report() const
Screen report.
Definition: error.cc:92
Milliseconds(const double &milliseconds)
Definition: libtime++.h:591
integer time_compare(time_Ts Date1, time_Ts Date2)
Definition: ctime_compare.c:35
TRange smallestcommon(const TRange &) const
find largest range common to both
Definition: ranges.cc:77
std::string hierarchicalstring() const
TRelativeTime & operator=(const time_kernel::time_Ts &A)
Definition: libtime++.h:505
bool operator>(const TRelativeTime &A) const
Definition: libtime++.h:429