ADTF  3.18.2
builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/datetime.h
Go to the documentation of this file.
1 
7 #ifndef _DATE_TIME_CLASS_HEADER_
8 #define _DATE_TIME_CLASS_HEADER_
9 
10 namespace A_UTILS_NS
11 {
12 #ifdef GetCurrentTime
13 #undef GetCurrentTime
14 #endif
20 class DOEXPORT cDate
21 {
23 
24  protected:
27 
28  public:
32  cDate();
33 
40  cDate(tInt nYear, tInt nMonth, tInt nDay);
41 
46  cDate(const tDate* psDate);
47 
52  cDate(const cDate& oDate);
53 
57  virtual ~cDate();
58 
64  cDate& operator= (const cDate& oDate);
65 
71 
77 
78  public:
85  tVoid Get(tDate* psDate) const;
86 
95  tVoid Set(tInt nYear, tInt nMonth, tInt nDay);
96 
103  tVoid Set(const tDate* psDate);
104 
111  tVoid Set(const cDate& oDate);
112 
120 
127  tInt GetDay() const;
128 
136  tVoid SetMonth(tInt nMonth);
137 
143  tInt GetMonth() const;
144 
157  tInt GetYear() const;
158 
164  tBool IsLeapYear() const;
165 
174  cString Format(const cString& strFormat) const;
175 
190 
191  public:
198  static tBool IsLeapYear(tInt nYear);
199 
216  static tResult GetDateFromString(cDate& oDate, const cString& strDate);
217 
225  static tInt GetNumOfDaysInMonth(const tInt nMonth, const tInt nYear);
226 
246  static tInt64 DateDiff(const cString& str, const cString& strDate1, const cString& strDate2);
247 
267  static tInt64 DateDiff(const cString& str, const cDate& oDate1, const cDate& oDate2);
268 };
269 
275 class DOEXPORT cTime
276 {
278 
279  protected:
282 
283  public:
287  cTime();
288 
296  cTime(tInt nHour, tInt nMinute, tInt nSecond, tInt nMicroseconds=0);
297 
302  cTime(const tTime* psTime);
303 
308  cTime(const cTime& oTime);
309 
315  cTime& operator= (const cTime& oTime);
316 
320  virtual ~cTime();
321 
327 
333 
334  public:
341  tVoid Get(tTime* psTime) const;
342 
352  tVoid Set(tInt nHour, tInt nMinute, tInt nSecond, tInt nMicroseconds=0);
353 
360  tVoid Set(const tTime* psTime);
361 
368  tVoid Set(const cTime& oTime);
369 
377 
383  tInt GetHour() const;
384 
391  tVoid SetMinute(tInt nMinute);
392 
398  tInt GetMinute() const;
399 
406  tVoid SetSecond(tInt nSecond);
407 
413  tInt GetSecond() const;
414 
421  tVoid SetMicroseconds(tInt nMicroseconds);
428 
434  cString Format(const cString& strFormat) const;
435 
448 
449  public:
466  static tResult GetTimeFromString(cTime& oTime, const cString& strTime);
467 
486  static tInt TimeDiff(const cString& str, const cString& strTime1, const cString& strTime2);
487 
506  static tInt TimeDiff(const cString& str, const cTime& oTime1, const cTime& oTime2);
507 
514 };
515 
521 class DOEXPORT cDateTime : public cDate, public cTime
522 {
524 
525  public:
530 
541  cDateTime(tInt nYear, tInt nMonth, tInt nDay, tInt nHour,
542  tInt nMinute, tInt nSecond, tInt nMicroseconds=0);
547  cDateTime(const tDateTime* psDateTime);
548 
553  cDateTime(const cDateTime& oDateTime);
554 
558  virtual ~cDateTime();
559 
565  cDateTime& operator= (const cDateTime& oDateTime);
566 
572 
578 
579  public:
586  tVoid Get(tDateTime* psDateTime) const;
587 
600  tVoid Set(tInt nYear, tInt nMonth, tInt nDay, tInt nHour,
601  tInt nMinute, tInt nSecond, tInt nMicroseconds=0);
602 
609  tVoid Set(const tDateTime* psDateTime);
610 
617  tVoid Set(const cDateTime& oDateTime);
618 
619  public:
626 
632  static cDateTime FromTimeStamp(tTimeStamp tmDateTime);
633 
641  static tTimeStamp GetDiff(const cDateTime& dt1, const cDateTime& dt2);
642 
679 #ifdef WIN32
693 #else
699 #endif // WIN32
707  cString Format(const cString& strFormat) const;
708 
730  tResult UnFormat(const cString& strFormat, const cString& strDateTime);
731 };
732 
733 } // namespace A_UTILS_NS
734 
735 #endif // _DATE_TIME_CLASS_HEADER_
int64_t tInt64
type definition for signed integer values (64bit) (platform and compiler independent type).
void tVoid
The tVoid is always the definition for the void (non-type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
cDate(const cDate &oDate)
Copy constructor.
tVoid Set(const cDate &oDate)
Sets the stored date.
cString Format(const cString &strFormat) const
Creates a string representation of the stored date.
tBool Valid()
Check whether or not the stored date is valid.
static tInt64 DateDiff(const cString &str, const cString &strDate1, const cString &strDate2)
Calculates the difference between two date strings.
tInt GetYear() const
Get the year.
static cDate GetCurrentSystemDate()
Retrieves the current system date (in UTC format).
static cDate GetCurrentDate()
Retrieves the current date (hardware clock with respect to timezone).
tInt GetDay() const
Get the day of the month.
cDate(const tDate *psDate)
Constructor that presets the stored date from a given data structure.
static tResult GetDateFromString(cDate &oDate, const cString &strDate)
Converts a given date string into a date and fill the given date.
virtual ~cDate()
Destructor.
tInt GetMonth() const
Get the month.
cDate(tInt nYear, tInt nMonth, tInt nDay)
Constructor for presetting the stored date.
static tInt GetNumOfDaysInMonth(const tInt nMonth, const tInt nYear)
Get the number of days of the given month and year (also consider the leap years).
tVoid SetDay(tInt nDay)
Sets the day of the month.
tVoid Set(const tDate *psDate)
Sets the stored date.
tVoid SetMonth(tInt nMonth)
Set the month.
tVoid Set(tInt nYear, tInt nMonth, tInt nDay)
Sets the stored date.
static tBool IsLeapYear(tInt nYear)
Check whether or not the specified year is a leap year.
tBool IsLeapYear() const
Check whether or not the stored year is a leap year.
tVoid Get(tDate *psDate) const
Fills a date structure with the stored values.
cDate()
Default constructor.
tVoid SetYear(tInt nYear)
Set the year.
static tInt64 DateDiff(const cString &str, const cDate &oDate1, const cDate &oDate2)
Calculates the difference between two dates.
static cDateTime FromTimeStamp(tTimeStamp tmDateTime)
Set stored data and time to a timestamp.
static cDateTime GetCurrentSystemDateTime()
Get the current date and time (in UTC format).
cDateTime()
Default constructor.
tResult UnFormat(const cString &strFormat, const cString &strDateTime)
converts a given string into a cDateTime.
tVoid Get(tDateTime *psDateTime) const
Fill a data and time structure with stored values.
static cDateTime GetCurrentDateTime()
Get the current date and time (hardware clock with respect to timezone).
virtual ~cDateTime()
Destructor.
cDateTime(const cDateTime &oDateTime)
Constructor for presetting the stored date and time.
cDateTime(const tDateTime *psDateTime)
Constructor for presetting the stored date and time.
tVoid Set(const tDateTime *psDateTime)
Set the stored date and time.
tVoid Set(tInt nYear, tInt nMonth, tInt nDay, tInt nHour, tInt nMinute, tInt nSecond, tInt nMicroseconds=0)
Set the stored date and time.
static tTimeStamp GetDiff(const cDateTime &dt1, const cDateTime &dt2)
Calculates the difference between two dates in microseconds.
cDateTime(tInt nYear, tInt nMonth, tInt nDay, tInt nHour, tInt nMinute, tInt nSecond, tInt nMicroseconds=0)
Constructor for presetting the stored date and time.
tVoid Set(const cDateTime &oDateTime)
Set the stored date and time.
tTimeStamp ToTimeStamp() const
Convert stored date and time to a timestamp.
tVoid Get(tTime *psTime) const
Fills a time structure with the stored values.
cString Format(const cString &strFormat) const
Creates a string representation of the stored time.
tBool Valid()
Check whether or not the stored time is valid.
static tResult GetTimeFromString(cTime &oTime, const cString &strTime)
Converts a given time string into a time and fill the given time.
tInt GetSecond() const
Get the second.
tInt GetHour() const
Get the hour.
static cTime FromTimeStamp(tTimeStamp tmTime)
Converts a given timestamp into a time.
cTime()
Default constructor.
tVoid Set(tInt nHour, tInt nMinute, tInt nSecond, tInt nMicroseconds=0)
Sets the stored time.
static tInt TimeDiff(const cString &str, const cString &strTime1, const cString &strTime2)
Calculates the difference between two time strings.
tVoid SetHour(tInt nHour)
Set the hour.
static cTime GetCurrentTime()
Get the current time (hardware clock with respect to timezone).
virtual ~cTime()
Destructor.
tVoid Set(const cTime &oTime)
Sets the stored time.
tInt Microseconds() const
Get the microsecond.
static tInt TimeDiff(const cString &str, const cTime &oTime1, const cTime &oTime2)
Calculates the difference between two times.
cTime(const cTime &oTime)
Copy constructor.
tVoid SetMinute(tInt nMinute)
Set the minute.
tVoid Set(const tTime *psTime)
Sets the stored time.
cTime(const tTime *psTime)
Constructor for presetting the stored time.
tVoid SetMicroseconds(tInt nMicroseconds)
Set the microsecond.
tVoid SetSecond(tInt nSecond)
Set the second.
tInt GetMinute() const
Get the minute.
cTime(tInt nHour, tInt nMinute, tInt nSecond, tInt nMicroseconds=0)
Constructor for presetting the stored time.
static cTime GetCurrentSystemTime()
Get the current time (in UTC format).
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11
Date Structure to define dates.
Definition: structs.h:25
Struct to handle date and time together.
Definition: structs.h:57
Time Structure to define Time.
Definition: structs.h:40