NAP
Public Types | Public Member Functions | List of all members
DateTime Class Referencefinal

#include <nap/datetime.h>

Public Types

enum  ConversionMode : int { Local = 0, GMT = 1 }
 

Public Member Functions

 DateTime ()
 
 DateTime (const SystemTimeStamp &timeStamp, ConversionMode mode)
 
 DateTime (const SystemTimeStamp &timeStamp)
 
 ~DateTime ()=default
 
int getYear () const
 
EMonth getMonth () const
 
int getWeek () const
 
int getDayInTheMonth () const
 
int getDayInTheYear () const
 
EDay getDay () const
 
int getHour () const
 
int getMinute () const
 
int getSecond () const
 
int getMilliSecond () const
 
bool isDaylightSaving () const
 
std::string toString () const
 
void setTimeStamp (const SystemTimeStamp &timeStamp)
 
const SystemTimeStampgetTimeStamp () const
 
bool operator< (const DateTime &other) const
 
bool operator== (const DateTime &other) const
 
bool operator!= (const DateTime &other) const
 
bool operator<= (const DateTime &other) const
 
bool operator>= (const DateTime &other) const
 

Description

Represents a point in time based on a system time stamp. This is a run-time only class that wraps a system time stamp for easier readability and use. To actually save (serialize) or read (deserialize) a particular point in time use a nap::TimeStamp or nap::Date object.

Member Enumeration Documentation

◆ ConversionMode

enum ConversionMode : int
strong

Specifies the way a timestamp is interpreted

Enumerator
Local 

Local time, including possible daylight saving adjustment.

GMT 

Greenwich Mean Time, excluding daylight saving adjustment.

Constructor & Destructor Documentation

◆ DateTime() [1/3]

DateTime ( )

The object is constructed using the system's local date and time

◆ DateTime() [2/3]

DateTime ( const SystemTimeStamp timeStamp,
ConversionMode  mode 
)
Parameters
timeStampthe time that defines this object's date and time
modethe way time is interpreted, local includes possible daylight savings, GMT does not

◆ DateTime() [3/3]

DateTime ( const SystemTimeStamp timeStamp)

When using this constructor time is interpreted as Local to the computer and includes daylight saving adjustments

Parameters
timeStampthe time that defines this object's date and time

◆ ~DateTime()

~DateTime ( )
default

Member Function Documentation

◆ getDay()

EDay getDay ( ) const
Returns
the day in the week since sunday (0,6) as a EDay

◆ getDayInTheMonth()

int getDayInTheMonth ( ) const
Returns
day of the month (1,31)

◆ getDayInTheYear()

int getDayInTheYear ( ) const
Returns
the day since january first (0,365)

◆ getHour()

int getHour ( ) const
Returns
the hour since midnight (0, 23)

◆ getMilliSecond()

int getMilliSecond ( ) const
Returns
the milliseconds associated with the time stamp

◆ getMinute()

int getMinute ( ) const
Returns
the minute after the hour (0,59)

◆ getMonth()

EMonth getMonth ( ) const
Returns
months since January (0, 11) as a EMonth where Sunday is 0 and Monday is 1

◆ getSecond()

int getSecond ( ) const
Returns
second after the minute (0,60)

◆ getTimeStamp()

const SystemTimeStamp& getTimeStamp ( ) const
Returns
the time stamp associated with this object

◆ getWeek()

int getWeek ( ) const
Returns
The ISO-8601 weeknumber: weeks start with Monday. Week 1 for a year is the week that contains the first Thursday for that year.

◆ getYear()

int getYear ( ) const
Returns
the year associated with the time stamp

◆ isDaylightSaving()

bool isDaylightSaving ( ) const
Returns
if this date time object takes in to account daylight savings

◆ operator!=()

bool operator!= ( const DateTime other) const

◆ operator<()

bool operator< ( const DateTime other) const

◆ operator<=()

bool operator<= ( const DateTime other) const

◆ operator==()

bool operator== ( const DateTime other) const

◆ operator>=()

bool operator>= ( const DateTime other) const

◆ setTimeStamp()

void setTimeStamp ( const SystemTimeStamp timeStamp)

Sets the time stamp that is used to define this object's date and time

Parameters
timeStampthe new TimeStamp

◆ toString()

std::string toString ( ) const
Returns
human readable string representation of the date and time