xoreos  0.0.5
Public Types | Public Member Functions | List of all members
Common::DateTime Class Reference

A date/time object, storing a specific point in time. More...

#include <datetime.h>

Inheritance diagram for Common::DateTime:
Inheritance graph
[legend]
Collaboration diagram for Common::DateTime:
Collaboration graph
[legend]

Public Types

enum  TimeZone { kUTC, kLocal }
 

Public Member Functions

 DateTime (TimeZone zone)
 Create a DateTime object from the current date and time. More...
 
 DateTime (const UString &value)
 Create a DateTime object by parsing a string representation of a specific date and time. More...
 
uint16 getYear () const
 Return the year in the Gregorian calendar. More...
 
uint8 getMonth () const
 Return the month in the Gregorian calendar (1..12). More...
 
uint8 getDay () const
 Return the day in the Gregorian calendar (1..31). More...
 
uint8 getHour () const
 Return the hour in the 24-hour clock (0..23). More...
 
uint8 getMinute () const
 Return the minute (0..59). More...
 
uint8 getSecond () const
 Return the second (0..60). More...
 
void getDate (uint16 &year, uint8 &month, uint8 &day) const
 Return the year, month (1..12) and day (1..31) in the Gregorian calendar. More...
 
void getTime (uint8 &hour, uint8 &minute, uint8 &second) const
 Return the hour in the 24-hour clock (0..23), minute (0..59) and second (0..60). More...
 
void getDateTime (uint16 &year, uint8 &month, uint8 &day, uint8 &hour, uint8 &minute, uint8 &second) const
 Return the year, month (1..12), day (1..31), hour (0..23), minute (0..59) and second (0..60). More...
 
UString formatDateISO (uint32 sep=0) const
 Return a string representation of the date in ISO 8601 format. More...
 
UString formatTimeISO (uint32 sep=0) const
 Return a string representation of the time in ISO 8601 format. More...
 
UString formatDateTimeISO (uint32 sep=0, uint32 sepDate=0, uint32 sepTime=0) const
 Return a string representation of the date and time in ISO 8601 format. More...
 

Detailed Description

A date/time object, storing a specific point in time.

Definition at line 36 of file datetime.h.

Member Enumeration Documentation

◆ TimeZone

Enumerator
kUTC 

Coordinated Universal Time (UTC).

kLocal 

The nondescript local time zone.

Definition at line 38 of file datetime.h.

Constructor & Destructor Documentation

◆ DateTime() [1/2]

Common::DateTime::DateTime ( TimeZone  zone)

Create a DateTime object from the current date and time.

Parameters
zoneThe time zone the current date and time should be expressed as. Can be either Coordinated Universal Time (UTC), or the local system time zone.

Note: The time zone is not stored within the object. It is only used to specify a base for the current time.

Definition at line 35 of file datetime.cpp.

References kLocal, and kUTC.

◆ DateTime() [2/2]

Common::DateTime::DateTime ( const UString value)

Create a DateTime object by parsing a string representation of a specific date and time.

Parameters
valueThe time value to parse. It has to be in YYYYmmDDTHHMMSS format, or YmdTHMS in strftime() notation, i.e. ISO 8601 format, with the date and the time separated by a 'T', but the individual parts of the date and time not separated at all.

Definition at line 50 of file datetime.cpp.

References Common::StackException::add(), and Common::UString::c_str().

Here is the call graph for this function:

Member Function Documentation

◆ formatDateISO()

UString Common::DateTime::formatDateISO ( uint32  sep = 0) const

Return a string representation of the date in ISO 8601 format.

The format will be YYYY-mm-DD, with YYYY being a 4 digit year in the Gregorian calendar, mm being a 2 digit month of the year (01..12) in the Gregorian calendar, DD being a 2 digit day of the month (01..31) in the Gregorian calendar, and - being a freely selectable separator character.

If the separator character is 0, no separator at all is used. The format of the string is then YYYYMMDD.

Parameters
sepUse this character as the separator character.

Definition at line 61 of file datetime.cpp.

References Common::UString::c_str(), and Common::UString::format().

Referenced by formatDateTimeISO().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatDateTimeISO()

UString Common::DateTime::formatDateTimeISO ( uint32  sep = 0,
uint32  sepDate = 0,
uint32  sepTime = 0 
) const

Return a string representation of the date and time in ISO 8601 format.

The format will be YYYY-mm-DDTHH:MM:SS, with T being a freely selectable separator character between the date and the time. For the formatting of the date and time, please see formatDateISO() and formatTimeISO().

If the separator character is 0, no separator at all is used. The format of the string is then YYYY-mm-DDHH:MM:SS.

Parameters
sepUse this character as the separator between date and time.
sepDateUse this character as the separator between the date elements.
sepTimeUse this character as the separator between the time elements.

Definition at line 79 of file datetime.cpp.

References Common::UString::c_str(), Common::UString::format(), formatDateISO(), and formatTimeISO().

Referenced by Graphics::constructFilename(), Common::DebugManager::logString(), Engines::DragonAge::Functions::logTrace(), Engines::DragonAge2::Functions::logTrace(), Engines::DragonAge::Functions::printToLog(), Engines::DragonAge2::Functions::printToLog(), Engines::DragonAge2::Functions::printToLogAndFlush(), Engines::DragonAge::Functions::printToLogAndFlush(), Engines::KotOR2::Functions::writeTimestampedLogEntry(), Engines::NWN::Functions::writeTimestampedLogEntry(), Engines::NWN2::Functions::writeTimestampedLogEntry(), Engines::Witcher::Functions::writeTimestampedLogEntry(), Engines::KotOR::Functions::writeTimestampedLogEntry(), and Engines::Jade::Functions::writeTimestampedLogEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatTimeISO()

UString Common::DateTime::formatTimeISO ( uint32  sep = 0) const

Return a string representation of the time in ISO 8601 format.

The format will be HH:MM:SS, with HH being a 2 digit hour in the 24-hour clock (00..23), MM being a 2 digit minute (00..59), SS being a 2 digit second (00..60, includes a potential leap second), and : being a freely selectable separator character.

If the separator character is 0, no separator at all is used. The format of the string is then HHMMSS.

Parameters
sepUse this character as the separator character.

Definition at line 70 of file datetime.cpp.

References Common::UString::c_str(), and Common::UString::format().

Referenced by formatDateTimeISO().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDate()

void Common::DateTime::getDate ( uint16 year,
uint8 month,
uint8 day 
) const
inline

Return the year, month (1..12) and day (1..31) in the Gregorian calendar.

Definition at line 77 of file datetime.h.

References getDay(), getMonth(), and getYear().

Referenced by getDateTime(), and Common::FoxPro::updateUpdate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDateTime()

void Common::DateTime::getDateTime ( uint16 year,
uint8 month,
uint8 day,
uint8 hour,
uint8 minute,
uint8 second 
) const
inline

Return the year, month (1..12), day (1..31), hour (0..23), minute (0..59) and second (0..60).

Definition at line 89 of file datetime.h.

References getDate(), and getTime().

Here is the call graph for this function:

◆ getDay()

uint8 Common::DateTime::getDay ( ) const
inline

Return the day in the Gregorian calendar (1..31).

Definition at line 67 of file datetime.h.

Referenced by getDate().

Here is the caller graph for this function:

◆ getHour()

uint8 Common::DateTime::getHour ( ) const
inline

Return the hour in the 24-hour clock (0..23).

Definition at line 70 of file datetime.h.

Referenced by getTime().

Here is the caller graph for this function:

◆ getMinute()

uint8 Common::DateTime::getMinute ( ) const
inline

Return the minute (0..59).

Definition at line 72 of file datetime.h.

Referenced by getTime().

Here is the caller graph for this function:

◆ getMonth()

uint8 Common::DateTime::getMonth ( ) const
inline

Return the month in the Gregorian calendar (1..12).

Definition at line 65 of file datetime.h.

Referenced by getDate().

Here is the caller graph for this function:

◆ getSecond()

uint8 Common::DateTime::getSecond ( ) const
inline

Return the second (0..60).

Definition at line 74 of file datetime.h.

Referenced by getTime().

Here is the caller graph for this function:

◆ getTime()

void Common::DateTime::getTime ( uint8 hour,
uint8 minute,
uint8 second 
) const
inline

Return the hour in the 24-hour clock (0..23), minute (0..59) and second (0..60).

Definition at line 83 of file datetime.h.

References getHour(), getMinute(), and getSecond().

Referenced by getDateTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getYear()

uint16 Common::DateTime::getYear ( ) const
inline

Return the year in the Gregorian calendar.

Definition at line 63 of file datetime.h.

Referenced by getDate().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: