158 inline static SP::CORE_Time
New(){
167 SP::CORE_Time p=
New();
176 SP::CORE_Time p=
New();
177 if (time!=
null) p->setDate(*time);
183 inline static SP::CORE_Time
New(
const tTime& time){
184 SP::CORE_Time p=
New();
191 inline static SP::CORE_Time
New(
const SP::CORE_Time& time){
192 SP::CORE_Time p=
New();
193 p->setDate(time.get());
207 t->setDate(year,month,day,0,0,1,0);
217 tTime secs=time->getSecondsSince1900();
225 tTime secs=time->getSecondsSince1900()*1000+time->getMilliSeconds();
249 if ((mMonth==0) && (mWeek>25)) year--;
250 if ((mMonth==11) && (mWeek<25)) year++;
285 t->setDate(mYear,mMonth+1,29,0,0,0,0);
286 if (t->getMonth()==2)
return 29;
400 setDate(year,month,day,hour,minutes,seconds,0);
439 if (time==
null)
return;
489 const SP::CORE_Time& time2);
500 return sub(time.get());
508 if (time!=
null)
return sub(*time);
523 const SP::CORE_Time& time2);
537 return sub(time.get());
544 if (time!=
null)
return sub(*time);
551 setDate(mSecondsSince1900+24*3600);
556 setDate(mSecondsSince1900-24*3600);
562 setDate(mSecondsSince1900-nDays*24*3600);
573 setDate(y,mo+1,mDay,mHours,mMinutes,mSeconds,0);
584 setDate(y,mo+1,mDay,mHours,mMinutes,mSeconds,0);
589 setDate(mSecondsSince1900+7*24*3600);
594 setDate(mSecondsSince1900-7*24*3600);
608 setDate(mSecondsSince1900-23*3600);
629 return (1000*(std::clock()-startTime))/CLOCKS_PER_SEC;
646 mStartHRClock=std::chrono::high_resolution_clock::now();
647 mIsHRClockChronoStarting=
true;
650 mStartSystemClock=std::chrono::system_clock::now();
651 mIsSystemClockChronoStarting=
true;
655 mStartClock=std::clock();
656 mIsClockChronoStarting=
true;
676 if (!mIsHRClockChronoStarting)
throw CORE_Exception(
"common/core/",
677 "CORE_Time::stopChronoTime()",
678 "can not stop a HR clock chrono without starting it");
680 nMilliSeconds=(
tULLInt) std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now()-
mStartHRClock).count();
681 mIsHRClockChronoStarting=
false;
684 if (!mIsSystemClockChronoStarting)
throw CORE_Exception(
"common/core/",
685 "CORE_Time::stopChronoTime()",
686 "can not stop a system clock chrono without starting it");
687 nMilliSeconds=(
tULLInt) std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()-
mStartSystemClock).count();
688 mIsSystemClockChronoStarting=
false;
693 "CORE_Time::stopChronoTime()",
694 "can not stop a clock chrono without starting it");
696 mIsClockChronoStarting=
false;
699 return nMilliSeconds;
729 if (t==
null)
return false;
751 if (t==
null)
return true;
789 return (mSecondsSince1900==t->getSecondsSince1900());
803 return (mSecondsSince1900>t->getSecondsSince1900());
817 return (mSecondsSince1900>=t->getSecondsSince1900());
847 return getDuration(duration,days,hours,minutes,seconds,ms);
871 static char *
_fmt(
const struct tm *t,
char *pt,
const char *ptlim);
872 static char *
_conv(
const int n,
const char *format,
char *pt,
const char *ptlim);
873 static char *
_add(
const char *str,
char *pt,
const char *ptlim);
875 static int getWeek(
const struct tm *t);
877 return (a>=0) ? a%b : a%b+b;
883 #endif // end of ifndef const tULLInt & getMilliSeconds() const
return the milliseconds seconds of the time
Definition: CORE_Time.h:363
const tUInteger & getMinutes() const
return the minutes of the time
Definition: CORE_Time.h:343
void setDate(tUInteger year, tUInteger month, tUInteger day)
set the date
Definition: CORE_Time.h:407
tUInteger getDay() const
return the day
Definition: CORE_Time.h:300
const tUInteger & getHours() const
return the hours of the time
Definition: CORE_Time.h:357
static SP::CORE_Time New()
creates a time object
Definition: CORE_Time.h:158
static SP::CORE_Time New(const tUInteger &year, const tUInteger &month, const tUInteger &day)
creates a time object year > 1900 month [1,12] day [1,31]
Definition: CORE_Time.h:203
virtual tString toString() const
return the time into a string
Definition: CORE_Time.cpp:344
void setDate(const tTime &seconds)
set the date from 1900 in seconds
Definition: CORE_Time.cpp:214
void setToNextWeek()
set to next week
Definition: CORE_Time.h:588
const tTime & getSecondsSince1900() const
return the number of seconds since 1900
Definition: CORE_Time.h:369
void startChronoTime()
Definition: CORE_Time.h:635
tULLInt continueChronoTime(const tFlag &f)
Definition: CORE_Time.h:716
tBoolean isAfter(const CORE_Time *t) const
return true if this > t
Definition: CORE_Time.h:765
void setToPreviousWeek()
set to previoust week
Definition: CORE_Time.h:593
static tString getDuration(const tULLInt &duration, tUInteger &days, tUInteger &hours, tUInteger &minutes, tUInteger &seconds, tUInteger &ms)
get duration
Definition: CORE_Time.cpp:598
void setDate(const CORE_Time *time)
set the date from a string year-month-day
Definition: CORE_Time.h:438
#define tUInteger
Definition: types.h:91
this class describes a time class
Definition: CORE_Time.h:64
tULInt continueChronoTime()
contune the chrono and return the time in ms since start time or last continue step the start time be...
Definition: CORE_Time.h:708
static tTime getDateInMilliSeconds()
return the time in 1/60 seconds
Definition: CORE_Time.h:223
void setToFirstWeekDay(const tUInteger &year, const tUInteger &week)
set the date to the first week day
Definition: CORE_Time.cpp:448
tBoolean isAfterOrEqual(const SP::CORE_Time &t) const
return true if this >= t
Definition: CORE_Time.h:816
void setToPreviousMonth()
set to previous month
Definition: CORE_Time.h:577
tString getWeekIntervalString()
get the week interval monday –> Sunday of the current time
Definition: CORE_Time.h:313
tBoolean isBeforeOrEqual(const SP::CORE_Time &t) const
return true if this <= t
Definition: CORE_Time.h:809
void setDate(const tUInteger &year, const tUInteger &month, const tUInteger &day, const tUInteger &hour, const tUInteger &minutes, const tUInteger &seconds)
set the date
Definition: CORE_Time.h:398
static const tFlag HOUR
Definition: CORE_Time.h:85
static tString getDuration(const tULLInt &duration)
get duration
Definition: CORE_Time.h:840
tULLInt getCPUTime() const
return the CPU time in 1/60 seconds
Definition: CORE_Time.h:238
static const tFlag DAY
Definition: CORE_Time.h:83
void setToPreviousDays(const tUInteger &nDays)
sun nDays from current day
Definition: CORE_Time.h:561
tBoolean mIsHRClockChronoStarting
Definition: CORE_Time.h:119
#define tBoolean
Definition: types.h:139
tLLInt sub(const CORE_Time *time) const
get the difference with this and time : this -time in secunds
Definition: CORE_Time.h:507
static const tFlag SECUND
Definition: CORE_Time.h:87
tBoolean isEqual(const CORE_Time *t) const
return true if the 2 dates are equals between this and t
Definition: CORE_Time.h:728
static SP::CORE_Time New(const SP::CORE_Time &time)
creates a time object
Definition: CORE_Time.h:191
tBoolean isEqual(const SP::CORE_Time &t) const
return true if the 2 dates are equals
Definition: CORE_Time.h:788
#define tTime
Definition: types.h:132
tULLInt stopChronoTime(const tFlag &f)
Definition: CORE_Time.h:671
#define null
Definition: types.h:144
static const tString JOURS[]
days names in french
Definition: CORE_Time.h:129
static SP::CORE_Time New(const tTime &time)
creates a time object
Definition: CORE_Time.h:183
static const tFlag SYSTEM_CLOCK_TIME
Definition: CORE_Time.h:73
tUInteger mMinutes
Definition: CORE_Time.h:103
static const tFlag MONTH
Definition: CORE_Time.h:81
tBoolean isBefore(const CORE_Time &t) const
return true if this < t
Definition: CORE_Time.h:743
tUInteger mDay
Definition: CORE_Time.h:99
static int getWeek(const struct tm *t)
Definition: CORE_Time.cpp:534
void setDate(const CORE_Time &time)
set the date from a string year-month-day
Definition: CORE_Time.h:420
tBoolean isAfterOrEqual(const CORE_Time &t) const
return true if this >= t
Definition: CORE_Time.h:781
CORE_Time()
create a general time object
Definition: CORE_Time.cpp:96
tULLInt mCPUTime
Definition: CORE_Time.h:109
tLLInt sub(const CORE_Time &time) const
get the difference with time this -time in secunds
Definition: CORE_Time.cpp:265
void setTimeType(const tFlag &f)
set the chrono time type
Definition: CORE_Time.h:614
static const tFlag CLOCK_TIME
Definition: CORE_Time.h:75
#define tULInt
Definition: types.h:39
tUInteger getMonth() const
return the month
Definition: CORE_Time.h:265
#define tLLInt
Definition: types.h:47
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
static const tFlag WEEK
Definition: CORE_Time.h:82
static char * _add(const char *str, char *pt, const char *ptlim)
Definition: CORE_Time.cpp:593
tUInteger mWeekDay
Definition: CORE_Time.h:97
tLLInt subInMilliSeconds(const CORE_Time &time) const
get the difference between this and time in milli-secunds
Definition: CORE_Time.cpp:273
tLLInt subInMilliSeconds(const SP::CORE_Time &time) const
get the difference between this and time in milli-secunds
Definition: CORE_Time.h:536
const tUInteger & getSeconds() const
return the seconds of the time
Definition: CORE_Time.h:350
static tFlag TIME_TYPE
Definition: CORE_Time.h:78
void setToNextDay()
set to next day
Definition: CORE_Time.h:550
tUInteger mSeconds
Definition: CORE_Time.h:105
void setHour(const tString &h)
set hour of the format HHhMM
Definition: CORE_Time.cpp:509
tBoolean isBeforeOrEqual(const CORE_Time &t) const
return true if this <= t
Definition: CORE_Time.h:774
tUInteger getDaysNumberInMonth() const
return the number of days in month
Definition: CORE_Time.h:272
static char * _fmt(const struct tm *t, char *pt, const char *ptlim)
Definition: CORE_Time.cpp:544
tUInteger mWeek
Definition: CORE_Time.h:95
void setToNextMonth()
set to next month
Definition: CORE_Time.h:566
std::chrono::high_resolution_clock::time_point mStartHRClock
Definition: CORE_Time.h:114
static const tString MOIS[]
month names in french
Definition: CORE_Time.h:136
static const tULLInt MAX_YEAR
MAX number of years.
Definition: CORE_Time.h:71
static tTime getDateInSeconds()
return the time in 1/60 seconds
Definition: CORE_Time.h:215
static const tFlag MILLI_SECUNDS
Definition: CORE_Time.h:88
tUInteger mMonth
Definition: CORE_Time.h:93
tUInteger mYear
Definition: CORE_Time.h:91
tUInteger getWeekYear(tUInteger &year) const
get the week of the year
Definition: CORE_Time.h:247
abstract base class for most classes.
Definition: CORE_Object.h:53
static const tString DAYS[]
days names in english
Definition: CORE_Time.h:126
static SP::CORE_Time New(const CORE_Time *time)
creates a time object
Definition: CORE_Time.h:175
std::chrono::system_clock::time_point mStartSystemClock
Definition: CORE_Time.h:115
tBoolean isBefore(const CORE_Time *t) const
return true if this < t
Definition: CORE_Time.h:750
void startChronoTime(const tFlag &f)
Definition: CORE_Time.h:642
#define tString
Definition: types.h:135
tLLInt subInMilliSeconds(const CORE_Time *time) const
get the difference with this and time: this -time in milli-secunds
Definition: CORE_Time.h:543
tBoolean mIsSystemClockChronoStarting
Definition: CORE_Time.h:120
static char * _conv(const int n, const char *format, char *pt, const char *ptlim)
Definition: CORE_Time.cpp:585
tBoolean mIsClockChronoStarting
Definition: CORE_Time.h:121
const tUInteger & getWeekDay() const
return the day of the week
Definition: CORE_Time.h:336
void setToLastDay(const tUInteger &year, const tUInteger &month)
set to last day of month
Definition: CORE_Time.h:600
static tUInteger modZ(const tInteger &a, const tInteger &b)
Definition: CORE_Time.h:876
static SP::CORE_Time New(const CORE_Time &time)
creates a time object
Definition: CORE_Time.h:166
void setToPreviousDay()
set to previous day
Definition: CORE_Time.h:555
static tULLInt getTime()
return the time in 1/60 seconds
Definition: CORE_Time.h:232
static const tFlag HR_CLOCK_TIME
Definition: CORE_Time.h:74
static tULLInt getClockTime()
Definition: CORE_Time.h:621
void setToWeekDay(const tUInteger &year, const tUInteger &week, const tUInteger &day)
set the date to the week day
Definition: CORE_Time.cpp:475
void setDate(SP::CORE_Time time)
set the date from a string year-month-day
Definition: CORE_Time.h:432
static tLLInt subTimesInMilliSeconds(const CORE_Time &time1, const CORE_Time &time2)
get the difference betwen two dates in milli-secund : time1-time2
Definition: CORE_Time.cpp:256
virtual ~CORE_Time()
remove
Definition: CORE_Time.cpp:160
static const tFlag YEAR
Definition: CORE_Time.h:80
tULLInt stopChronoTime()
end the chrono and return the time in seconds since start time
Definition: CORE_Time.h:663
tUInteger mHours
Definition: CORE_Time.h:101
tLLInt sub(const SP::CORE_Time &time) const
get the difference with this and time: this -time in secunds
Definition: CORE_Time.h:499
#define tULLInt
Definition: types.h:45
static const tFlag WEEK_DAY
Definition: CORE_Time.h:84
tTime mSecondsSince1900
Definition: CORE_Time.h:111
tBoolean isAfter(const CORE_Time &t) const
return true if this > t
Definition: CORE_Time.h:758
static const tFlag MINUTE
Definition: CORE_Time.h:86
tBoolean isEqual(const CORE_Time &t) const
return true if the 2 dates are equals between this and t
Definition: CORE_Time.h:736
tULLInt mMilliSeconds
Definition: CORE_Time.h:107
tBoolean isAfter(const SP::CORE_Time &t) const
return true if this > t
Definition: CORE_Time.h:802
static const tString MONTHS[]
month names in english
Definition: CORE_Time.h:133
static tLLInt subTimes(const CORE_Time &time1, const CORE_Time &time2)
get the difference between two dates in secund time1-time2
Definition: CORE_Time.cpp:253
tBoolean isBefore(const SP::CORE_Time &t) const
return true if this < t
Definition: CORE_Time.h:795
#define tInteger
Definition: types.h:90
const tUInteger & getYear() const
return the year
Definition: CORE_Time.h:258
void setTime(const tUInteger &hour, const tUInteger &minutes, const tUInteger &seconds)
set the time
Definition: CORE_Time.cpp:228
static tULLInt getClockDuration(const tULLInt &startTime)
Definition: CORE_Time.h:628
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
#define tFlag
Definition: types.h:74
tULLInt mStartClock
Definition: CORE_Time.h:116