70 static const tFlag YEAR;
71 static const tFlag MONTH;
72 static const tFlag WEEK;
73 static const tFlag DAY;
74 static const tFlag WEEK_DAY;
75 static const tFlag HOUR;
76 static const tFlag MINUTE;
77 static const tFlag SECUND;
78 static const tFlag MILLI_SECUNDS;
97 unsigned long long int mMilliSeconds;
99 unsigned long long int mCPUTime;
101 tTime mSecondsSince1900;
102 std::clock_t mStartClock;
139 inline static SP::CORE_Time
New(){
146 SP::CORE_Time p=
New();
153 SP::CORE_Time p=
New();
154 if (time!=
null) p->setDate(*time);
159 inline static SP::CORE_Time
New(
const tTime& time){
160 SP::CORE_Time p=
New();
166 inline static SP::CORE_Time
New(
const SP::CORE_Time& time){
167 SP::CORE_Time p=
New();
168 p->setDate(time.get());
174 inline static SP::CORE_Time
New(
const int& year,
178 t->setDate(year,month,day,0,0,1,0);
187 tTime secs=time->getSecondsSince1900();
194 tTime secs=time->getSecondsSince1900()*1000+time->getMilliSeconds();
216 if ((mMonth==0) && (mWeek>25)) year--;
217 if ((mMonth==11) && (mWeek<25)) year++;
249 t->setDate(mYear,mMonth+1,29,0,0,0,0);
250 if (t->getMonth()==2)
return 29;
287 void setToWeekDay(
const int& year,
const int& week,
const int& day);
321 return mMilliSeconds;
326 return mSecondsSince1900;
339 void setDate(
const int& year,
const int& month,
const int& day,
340 const int& hour,
const int& minutes,
const int& seconds,
const int& ms);
346 inline void setDate(
const int& year,
const int& month,
const int& day,
347 const int& hour,
const int& minutes,
const int& seconds) {
348 setDate(year,month,day,hour,minutes,seconds,0);
382 if (time==
null)
return;
411 void setTime(
const int& hour,
const int& minutes,
const int& seconds);
422 const SP::CORE_Time& time2);
429 return sub(time2.get());
434 if (time2!=
null)
return sub(*time2);
444 const SP::CORE_Time& time2);
451 return sub(time2.get());
456 if (time2!=
null)
return sub(*time2);
463 setDate(mSecondsSince1900+24*3600);
468 setDate(mSecondsSince1900-24*3600);
473 setDate(mSecondsSince1900-nDays*24*3600);
484 setDate(y,mo+1,mDay,mHours,mMinutes,mSeconds,0);
495 setDate(y,mo+1,mDay,mHours,mMinutes,mSeconds,0);
500 setDate(mSecondsSince1900+7*24*3600);
505 setDate(mSecondsSince1900-7*24*3600);
517 setDate(mSecondsSince1900-23*3600);
523 mIsChronoStarting=
true;
524 mStartClock=std::clock();
531 "can not continue a chrono without starting it");
532 std::clock_t t=std::clock();
533 unsigned long long int dt=(
unsigned long long int) (1000.0*(t-mStartClock)/CLOCKS_PER_SEC);
543 "can not stop a chrono without starting it");
544 mIsChronoStarting=
false;
545 return (
unsigned long long int) (1000.0*(std::clock()-mStartClock)/CLOCKS_PER_SEC);
551 if (t==
null)
return false;
567 if (t==
null)
return true;
595 return (mSecondsSince1900==t->getSecondsSince1900());
605 return (mSecondsSince1900>t->getSecondsSince1900());
615 return (mSecondsSince1900>=t->getSecondsSince1900());
635 return getDuration(duration,days,hours,minutes,seconds,ms);
657 static char *_fmt(
const struct tm *t,
char *pt,
const char *ptlim);
658 static char *_conv(
const int n,
const char *format,
char *pt,
const char *ptlim);
659 static char *_add(
const char *str,
char *pt,
const char *ptlim);
661 static int getWeek(
const struct tm *t);
665 #endif // end of ifndef
tBoolean isBeforeOrEqual(const SP::CORE_Time &t) const
return true if this <= t
Definition: CORE_Time.h:609
unsigned long long int getMilliSeconds() const
return the milliseconds seconds of the time
Definition: CORE_Time.h:320
static const tTime MAX_YEAR
MAX number of years.
Definition: CORE_Time.h:68
tTime getSecondsSince1900() const
return the number of seconds since 1900
Definition: CORE_Time.h:325
static SP::CORE_Time New()
creates a time object
Definition: CORE_Time.h:139
void setDate(const tTime &seconds)
set the date from 1900 in seconds
Definition: CORE_Time.cpp:205
int getYear() const
return the year
Definition: CORE_Time.h:224
unsigned long long int getCPUTime() const
return the CPU time in 1/60 seconds
Definition: CORE_Time.h:205
void setToNextWeek()
set to next week
Definition: CORE_Time.h:499
unsigned long long int stopChrono()
end the chrono and return the time in ms since start time
Definition: CORE_Time.h:540
void setToPreviousWeek()
set to previoust week
Definition: CORE_Time.h:504
void setDate(const CORE_Time *time)
set the date from a string year-month-day
Definition: CORE_Time.h:381
this class describes a time class
Definition: CORE_Time.h:61
tBoolean isAfter(const SP::CORE_Time &t) const
return true if this > t
Definition: CORE_Time.h:604
static tTime getDateInMilliSeconds()
return the time in 1/60 seconds
Definition: CORE_Time.h:192
int getMinutes() const
return the minutes of the time
Definition: CORE_Time.h:301
void setToPreviousMonth()
set to previous month
Definition: CORE_Time.h:488
tString getWeekIntervalString()
get the week interval monday –> Sunday of the current time
Definition: CORE_Time.h:273
void startChrono()
start the chrono
Definition: CORE_Time.h:522
#define tRelativeInteger
Definition: types.h:46
static tString getDuration(const long int &duration, int &days, int &hours, int &minutes, int &seconds, int &ms)
get duration
Definition: CORE_Time.cpp:577
void setToWeekDay(const int &year, const int &week, const int &day)
set the date to the week day week must be in [1..53] day in [0,6] 0:MONDAY....6:SUNDAY the first day ...
Definition: CORE_Time.cpp:454
#define tBoolean
Definition: types.h:48
unsigned long long int continueChrono()
contune the chrono and return the time in ms since start time or last continue step ...
Definition: CORE_Time.h:528
tBoolean isAfterOrEqual(const CORE_Time &t) const
return true if this >= t
Definition: CORE_Time.h:589
tBoolean isBefore(const CORE_Time *t) const
return true if this < t
Definition: CORE_Time.h:566
static SP::CORE_Time New(const SP::CORE_Time &time)
creates a time object
Definition: CORE_Time.h:166
#define tTime
Definition: types.h:54
#define null
Definition: types.h:13
tBoolean isEqual(const CORE_Time *t) const
return true if the 2 dates are equals
Definition: CORE_Time.h:550
static const tString JOURS[]
days names in french
Definition: CORE_Time.h:111
static SP::CORE_Time New(const tTime &time)
creates a time object
Definition: CORE_Time.h:159
int getDaysNumberInMonth() const
return the number of days in month
Definition: CORE_Time.h:236
int getSeconds() const
return the seconds of the time
Definition: CORE_Time.h:308
void setDate(const CORE_Time &time)
set the date from a string year-month-day
Definition: CORE_Time.h:365
static long int getTime()
return the time in 1/60 seconds
Definition: CORE_Time.h:200
tRelativeInteger subInMilliSeconds(const CORE_Time *time2) const
get the difference with time2 this -time2 in secunds
Definition: CORE_Time.h:455
CORE_Time()
create a general time object
Definition: CORE_Time.cpp:90
void setToLastDay(const int &year, const int &month)
set to last day of month
Definition: CORE_Time.h:509
tBoolean isAfter(const CORE_Time &t) const
return true if this > t
Definition: CORE_Time.h:572
void setToPreviousDays(const int &nDays)
set to days ago
Definition: CORE_Time.h:472
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
tBoolean isAfter(const CORE_Time *t) const
return true if this > t
Definition: CORE_Time.h:577
void setToNextDay()
set to next day
Definition: CORE_Time.h:462
void setTime(const int &hour, const int &minutes, const int &seconds)
set the time
Definition: CORE_Time.cpp:219
void setHour(const tString &h)
set hour xxhyy
Definition: CORE_Time.cpp:488
static tRelativeInteger subTimesInMilliSeconds(const CORE_Time &time1, const CORE_Time &time2)
get the difference betwen two dates in milli-secund time1-time2
Definition: CORE_Time.cpp:247
void setToNextMonth()
set to next month
Definition: CORE_Time.h:477
static const tString MOIS[]
month names in french
Definition: CORE_Time.h:118
static tRelativeInteger subTimes(const CORE_Time &time1, const CORE_Time &time2)
get the difference betwen two dates in secund time1-time2
Definition: CORE_Time.cpp:244
static tTime getDateInSeconds()
return the time in 1/60 seconds
Definition: CORE_Time.h:185
int getWeekYear(int &year) const
get the week of the year
Definition: CORE_Time.h:214
void setDate(int year, int month, int day)
set the date year>=0 month in [1,12]
Definition: CORE_Time.h:354
tRelativeInteger sub(const CORE_Time *time2) const
get the difference with time2 this -time2 in secunds
Definition: CORE_Time.h:433
abstract base class for most classes.
Definition: CORE_Object.h:30
static const tString DAYS[]
days names in english
Definition: CORE_Time.h:108
static SP::CORE_Time New(const CORE_Time *time)
creates a time object
Definition: CORE_Time.h:152
int getWeekDay() const
return the day of the week 0:Sunday [0..6]
Definition: CORE_Time.h:294
#define tString
Definition: types.h:49
tRelativeInteger subInMilliSeconds(const CORE_Time &time2) const
get the difference with time2 this -time2 in secunds
Definition: CORE_Time.cpp:264
static tString getDuration(const long int &duration)
get duration
Definition: CORE_Time.h:628
tBoolean isBeforeOrEqual(const CORE_Time &t) const
return true if this <= t
Definition: CORE_Time.h:584
tBoolean isEqual(const CORE_Time &t) const
return true if the 2 dates are equals
Definition: CORE_Time.h:556
static SP::CORE_Time New(const CORE_Time &time)
creates a time object
Definition: CORE_Time.h:145
void setToPreviousDay()
set to previous day
Definition: CORE_Time.h:467
static SP::CORE_Time New(const int &year, const int &month, const int &day)
creates a time object year > 1900 month [1,12] day [1,31]
Definition: CORE_Time.h:174
void setToFirstWeekDay(const int &year, const int &week)
set the date to the first week day week must be in [1..53] the first day is a monday ...
Definition: CORE_Time.cpp:427
tBoolean isBefore(const SP::CORE_Time &t) const
return true if this < t
Definition: CORE_Time.h:599
void setDate(SP::CORE_Time time)
set the date from a string year-month-day
Definition: CORE_Time.h:376
tRelativeInteger sub(const SP::CORE_Time &time2) const
get the difference with time2 this -time2 in secunds
Definition: CORE_Time.h:428
virtual tString toString() const
return the time into a string
Definition: CORE_Time.cpp:323
virtual ~CORE_Time()
remove
Definition: CORE_Time.cpp:151
tRelativeInteger subInMilliSeconds(const SP::CORE_Time &time2) const
get the difference with time2 this -time2 in secunds
Definition: CORE_Time.h:450
int getMonth() const
return the month
Definition: CORE_Time.h:231
tBoolean isAfterOrEqual(const SP::CORE_Time &t) const
return true if this >= t
Definition: CORE_Time.h:614
int getDay() const
return the day
Definition: CORE_Time.h:264
int getHours() const
return the hours of the time
Definition: CORE_Time.h:315
tRelativeInteger sub(const CORE_Time &time2) const
get the difference with time2 this -time2 in secunds
Definition: CORE_Time.cpp:256
static const tString MONTHS[]
month names in english
Definition: CORE_Time.h:115
tBoolean isBefore(const CORE_Time &t) const
return true if this < t
Definition: CORE_Time.h:561
void setDate(const int &year, const int &month, const int &day, const int &hour, const int &minutes, const int &seconds)
set the date year>=0 month in [1,12] day in [1,31]
Definition: CORE_Time.h:346
tBoolean isEqual(const SP::CORE_Time &t) const
return true if the 2 dates are equals
Definition: CORE_Time.h:594
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14