Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::Time Class Reference

Time object. More...

Inheritance diagram for gem::Time:
Collaboration diagram for gem::Time:

Public Member Functions

 Time ()=default
 Default constructor.
 Time (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0)
 Constructor from int as Timestamp with millis.
 Time (LargeInteger longTimeStamp)
 Constructor from LargeInteger as timestamp in millis from 1970 ( epoch ).
 Time (const Time &time)=default
 Default copy constructor.
 Time (Time &&time)=default
 Default move constructor noexcept is deduced.
Timeoperator= (const Time &time)=default
 Default copy assignment.
Timeoperator= (Time &&time)=default
 Default move assignment noexcept is deduced.
bool operator== (const Time &rhs) const noexcept
 Comparison operator equal.
bool operator!= (const Time &rhs) const noexcept
 Comparison operator not equal.
bool operator< (const Time &rhs) const noexcept
 Comparison operator smaller.
bool operator<= (const Time &rhs) const noexcept
 Comparison operator smaller or equal.
bool operator> (const Time &rhs) const noexcept
 Comparison operator greater.
bool operator>= (const Time &rhs) const noexcept
 Comparison operator greater or equal.
bool isValid () const noexcept
 Check if the date is valid.
bool empty () const noexcept
 Check if the date is empty value.
LargeInteger getEpoch () const noexcept
 Number of milliseconds that have passed since 1970-01-01T00:00:00.
TimesetUniversalTime () noexcept
 Set this instance to universal time.
TimesetLocalTime () noexcept
 Set this instance to local time.
LargeInteger asInt () const noexcept
 Number of milliseconds that have passed since 1970-01-01T00:00:00.
TimefromInt (LargeInteger timestamp) noexcept
 Set the time from a timestamp.
Timeoperator+= (LargeInteger millisecs) noexcept
 Add milliseconds.
Timeoperator-= (LargeInteger millisecs) noexcept
 Subtract milliseconds.
Time operator+ (LargeInteger millisecs) noexcept
 Add milliseconds.
Time operator- (LargeInteger millisecs) noexcept
 Subtract milliseconds.
LargeInteger operator- (const Time &time) const noexcept
 Subtract two times.
int getYear () const noexcept
 Get the year.
TimesetYear (int year) noexcept
 Set the year.
int getMonth () const noexcept
 Get the month.
TimesetMonth (int month) noexcept
 Set the month.
int getDay () const noexcept
 Get the day.
TimesetDay (int day) noexcept
 Set the day.
int getDayOfWeek () const noexcept
 Get the day of the week.
int getHour () const noexcept
 Get the hour.
TimesetHour (int hour) noexcept
 Set the hour.
int getMinute () const noexcept
 Get the minute.
TimesetMinute (int minute) noexcept
 Set the minute.
int getSecond () const noexcept
 Get the second.
TimesetSecond (int second) noexcept
 Set the second.
int getMillisecond () const noexcept
 Get the millisecond.
TimesetMillisecond (int millisecond) noexcept
 Set the millisecond.
String toStr (bool utcTime) const noexcept
 Format string conform to ISO8601.
TimefromStr (const String &str, bool utcTime) noexcept
 Set time object from an ISO8601 string.

Static Public Member Functions

static void milliSecondSleep (unsigned int msec) noexcept
 Sleep in this thread for specified number of milliseconds.
static Time getLocalTime () noexcept
 Returns a time object with local time.
static Time getUniversalTime () noexcept
 Returns a time object with universal time.
static LargeInteger getTimeZoneMilliseconds () noexcept
 Get time zone in milliseconds.
static LargeInteger toMilliseconds (LargeInteger days, LargeInteger hours, LargeInteger minutes, LargeInteger seconds, LargeInteger milliseconds) noexcept
 Convert a time interval in milliseconds.
static LargeInteger daysFromMilliseconds (LargeInteger ms) noexcept
 extract days from a time interval in milliseconds
static LargeInteger hoursFromMilliseconds (LargeInteger ms, bool remaining) noexcept
 extract hours from a time interval in milliseconds
static LargeInteger minutesFromMilliseconds (LargeInteger ms, bool remaining) noexcept
 extract minutes from a time interval in milliseconds
static LargeInteger secondsFromMilliseconds (LargeInteger ms, bool remaining) noexcept
 extract seconds from a time interval in milliseconds

Detailed Description

Time object.

Implements share-read / copy-on-write Api object over ITime.

Constructor & Destructor Documentation

◆ Time() [1/4]

gem::Time::Time ( int year,
int month,
int day,
int hour = 0,
int minute = 0,
int second = 0,
int millisecond = 0 )
inline

Constructor from int as Timestamp with millis.

Parameters
[in]yearYear
[in]monthMonth
[in]dayDay
[in]hourHour
[in]minuteMinute
[in]secondSecond
[in]millisecondMillisecond

◆ Time() [2/4]

gem::Time::Time ( LargeInteger longTimeStamp)
inline

Constructor from LargeInteger as timestamp in millis from 1970 ( epoch ).

Parameters
[in]longTimeStampTimestamp in milliseconds

◆ Time() [3/4]

gem::Time::Time ( const Time & time)
default

Default copy constructor.

Parameters
[in]timeTime object to copy

◆ Time() [4/4]

gem::Time::Time ( Time && time)
default

Default move constructor noexcept is deduced.

Parameters
[in]timeTime object to move

Member Function Documentation

◆ asInt()

LargeInteger gem::Time::asInt ( ) const
inlinenoexcept

Number of milliseconds that have passed since 1970-01-01T00:00:00.

Returns
Number of milliseconds

◆ daysFromMilliseconds()

LargeInteger gem::Time::daysFromMilliseconds ( LargeInteger ms)
inlinestaticnoexcept

extract days from a time interval in milliseconds

Parameters
[in]msTime interval in milliseconds
Returns
Days

◆ empty()

bool gem::Time::empty ( ) const
inlinenoexcept

Check if the date is empty value.

Returns
True if empty, false otherwise

◆ fromInt()

Time & gem::Time::fromInt ( LargeInteger timestamp)
inlinenoexcept

Set the time from a timestamp.

Timestamp is the number of milliseconds that have passed since 1970-01-01T00:00:00.

Parameters
[in]timestampTimestamp in milliseconds
Returns
Reference to this object

◆ fromStr()

Time & gem::Time::fromStr ( const String & str,
bool utcTime )
inlinenoexcept

Set time object from an ISO8601 string.

Parameters
[in]strISO8601 string
[in]utcTimeTime should be considered as UTC
Returns
Reference to this object

◆ getDay()

int gem::Time::getDay ( ) const
inlinenoexcept

Get the day.

Valid values 1..31

Returns
Day

◆ getDayOfWeek()

int gem::Time::getDayOfWeek ( ) const
inlinenoexcept

Get the day of the week.

Valid values 1..7 (1 being Sunday).

Returns
Day of the week

◆ getEpoch()

LargeInteger gem::Time::getEpoch ( ) const
inlinenoexcept

Number of milliseconds that have passed since 1970-01-01T00:00:00.

Returns
Number of milliseconds

◆ getHour()

int gem::Time::getHour ( ) const
inlinenoexcept

Get the hour.

Valid values 0..23

Returns
Hour

◆ getLocalTime()

Time gem::Time::getLocalTime ( )
inlinestaticnoexcept

Returns a time object with local time.

Returns
Time object with local time

◆ getMillisecond()

int gem::Time::getMillisecond ( ) const
inlinenoexcept

Get the millisecond.

Valid values 0..999

Returns
Millisecond

◆ getMinute()

int gem::Time::getMinute ( ) const
inlinenoexcept

Get the minute.

Valid values 0..59

Returns
Minute

◆ getMonth()

int gem::Time::getMonth ( ) const
inlinenoexcept

Get the month.

Valid values 1..12

Returns
Month

◆ getSecond()

int gem::Time::getSecond ( ) const
inlinenoexcept

Get the second.

Valid values 0..59

Returns
Second

◆ getTimeZoneMilliseconds()

LargeInteger gem::Time::getTimeZoneMilliseconds ( )
inlinestaticnoexcept

Get time zone in milliseconds.

Returns
Time zone in milliseconds

◆ getUniversalTime()

Time gem::Time::getUniversalTime ( )
inlinestaticnoexcept

Returns a time object with universal time.

Returns
Time object with universal time

◆ getYear()

int gem::Time::getYear ( ) const
inlinenoexcept

Get the year.

Returns
Year

◆ hoursFromMilliseconds()

LargeInteger gem::Time::hoursFromMilliseconds ( LargeInteger ms,
bool remaining )
inlinestaticnoexcept

extract hours from a time interval in milliseconds

Parameters
[in]remainingIf true returns the hours less than 1 day, if false returns total hours
[in]msTime interval in milliseconds
Returns
Hours

◆ isValid()

bool gem::Time::isValid ( ) const
inlinenoexcept

Check if the date is valid.

Returns
True if valid, false otherwise

◆ milliSecondSleep()

void gem::Time::milliSecondSleep ( unsigned int msec)
inlinestaticnoexcept

Sleep in this thread for specified number of milliseconds.

Parameters
[in]msecNumber of milliseconds to sleep

◆ minutesFromMilliseconds()

LargeInteger gem::Time::minutesFromMilliseconds ( LargeInteger ms,
bool remaining )
inlinestaticnoexcept

extract minutes from a time interval in milliseconds

Parameters
[in]remainingIf true returns the minutes less than 1 hour, if false returns total minutes
[in]msTime interval in milliseconds
Returns
Minutes

◆ operator!=()

bool gem::Time::operator!= ( const Time & rhs) const
inlinenoexcept

Comparison operator not equal.

Parameters
[in]rhsTime object to compare
Returns
True if not equal, false otherwise

◆ operator+()

Time gem::Time::operator+ ( LargeInteger millisecs)
inlinenoexcept

Add milliseconds.

Parameters
[in]millisecsMilliseconds to add
Returns
new Time object( this + millisecs)

◆ operator+=()

Time & gem::Time::operator+= ( LargeInteger millisecs)
inlinenoexcept

Add milliseconds.

Parameters
[in]millisecsMilliseconds to add
Returns
Reference to this object

◆ operator-() [1/2]

LargeInteger gem::Time::operator- ( const Time & time) const
inlinenoexcept

Subtract two times.

Parameters
timeTime to subtract
Returns
the number of milliseconds between this and time

◆ operator-() [2/2]

Time gem::Time::operator- ( LargeInteger millisecs)
inlinenoexcept

Subtract milliseconds.

Parameters
millisecsMilliseconds to subtract
Returns
new Time object( this - millisecs)

◆ operator-=()

Time & gem::Time::operator-= ( LargeInteger millisecs)
inlinenoexcept

Subtract milliseconds.

Parameters
millisecsMilliseconds to subtract
Returns
Reference to this object

◆ operator<()

bool gem::Time::operator< ( const Time & rhs) const
inlinenoexcept

Comparison operator smaller.

Parameters
[in]rhsTime object to compare
Returns
True if smaller, false otherwise

◆ operator<=()

bool gem::Time::operator<= ( const Time & rhs) const
inlinenoexcept

Comparison operator smaller or equal.

Parameters
rhsTime object to compare
Returns
True if smaller or equal, false otherwise

◆ operator=() [1/2]

Time & gem::Time::operator= ( const Time & time)
default

Default copy assignment.

Parameters
[in]timeTime object to copy
Returns
Reference to this object

◆ operator=() [2/2]

Time & gem::Time::operator= ( Time && time)
default

Default move assignment noexcept is deduced.

Parameters
[in]timeTime object to move
Returns
Reference to this object

◆ operator==()

bool gem::Time::operator== ( const Time & rhs) const
inlinenoexcept

Comparison operator equal.

Parameters
[in]rhsTime object to compare
Returns
True if equal, false otherwise

◆ operator>()

bool gem::Time::operator> ( const Time & rhs) const
inlinenoexcept

Comparison operator greater.

Parameters
[in]rhsTime object to compare
Returns
True if greater, false otherwise

◆ operator>=()

bool gem::Time::operator>= ( const Time & rhs) const
inlinenoexcept

Comparison operator greater or equal.

Parameters
rhsTime object to compare
Returns
True if greater or equal, false otherwise

◆ secondsFromMilliseconds()

LargeInteger gem::Time::secondsFromMilliseconds ( LargeInteger ms,
bool remaining )
inlinestaticnoexcept

extract seconds from a time interval in milliseconds

Parameters
[in]remainingIf true returns the seconds less than 1 minute, if false returns total seconds
[in]msTime interval in milliseconds
Returns
Seconds

◆ setDay()

Time & gem::Time::setDay ( int day)
inlinenoexcept

Set the day.

Valid values 1..31

Parameters
[in]dayDay
Returns
Reference to this object

◆ setHour()

Time & gem::Time::setHour ( int hour)
inlinenoexcept

Set the hour.

Valid values 0..23

Parameters
[in]hourHour
Returns
Reference to this object

◆ setLocalTime()

Time & gem::Time::setLocalTime ( )
inlinenoexcept

Set this instance to local time.

Returns
Reference to this object

◆ setMillisecond()

Time & gem::Time::setMillisecond ( int millisecond)
inlinenoexcept

Set the millisecond.

Valid values 0..999

Parameters
[in]millisecondMillisecond
Returns
Reference to this object

◆ setMinute()

Time & gem::Time::setMinute ( int minute)
inlinenoexcept

Set the minute.

Valid values 0..59

Parameters
[in]minuteMinute
Returns
Reference to this object

◆ setMonth()

Time & gem::Time::setMonth ( int month)
inlinenoexcept

Set the month.

Valid values 1..12

Parameters
[in]monthMonth
Returns
Reference to this object

◆ setSecond()

Time & gem::Time::setSecond ( int second)
inlinenoexcept

Set the second.

Valid values 0..59

Parameters
[in]secondSecond
Returns
Reference to this object

◆ setUniversalTime()

Time & gem::Time::setUniversalTime ( )
inlinenoexcept

Set this instance to universal time.

Returns
Reference to this object

◆ setYear()

Time & gem::Time::setYear ( int year)
inlinenoexcept

Set the year.

Parameters
[in]yearYear
Returns
Reference to this object

◆ toMilliseconds()

LargeInteger gem::Time::toMilliseconds ( LargeInteger days,
LargeInteger hours,
LargeInteger minutes,
LargeInteger seconds,
LargeInteger milliseconds )
inlinestaticnoexcept

Convert a time interval in milliseconds.

Parameters
[in]daysDays
[in]hoursHours
[in]minutesMinutes
[in]secondsSeconds
[in]millisecondsMilliseconds
Returns
Time interval in milliseconds

◆ toStr()

String gem::Time::toStr ( bool utcTime) const
inlinenoexcept

Format string conform to ISO8601.

Parameters
[in]utcTimeTime should be considered as UTC
Returns
ISO8601 string