commonlib
UTCTime Class Referencefinal

Public Member Functions

 UTCTime (int32_t hours, int32_t minutes, double seconds, int32_t day, int32_t month, int32_t year) noexcept
 Constructs UTCTime from human readable time and date, parameters over their limits are handled and corrected unless the time passed is earlier than the start of unix time. More...
 
 UTCTime (int64_t unixTime, double secondsFraction) noexcept
 Constructs UTCTime from unix time seconds and seconds fraction. More...
 
 UTCTime (double dateTime) noexcept
 Constructs GPSTimeUTC from Delphi TDateTime value which is defined as double type. More...
 
int32_t getHours () const
 Hours of day [0, 23]. More...
 
int32_t getMinutes () const
 Minutes of hour [0, 59]. More...
 
int32_t getSeconds () const
 Seconds of minute with fractional part [0, 59]. More...
 
double getSecondsFraction () const
 Fractional part of a second [0.0, 1.0) More...
 
int32_t getDay () const
 Day of month [1, 31]. More...
 
int32_t getMonth () const
 Month of year [1, 12]. More...
 
int32_t getYear () const
 Years of Common Era [1970, INF) More...
 
double getDateTimeValue () const
 UTC days since 30-Dec-1899 UTC, fractional part represents ratio of day. More...
 
int64_t getUnixTimeValue () const
 Integer number of seconds since start of Unix time on 01-Jan-1970 UTC. More...
 

Static Public Member Functions

static double RelativeSecondsBetween (const UTCTime &start, const UTCTime &end)
 Calculates relative seconds between two UTC times. More...
 
static UTCTime IncrementSeconds (const UTCTime &time, double secondsIncrement)
 Increments UTC time by positive or negative amount of seconds, the maximum size of an increment is equal to max int32 - 60 (approx. More...
 

Static Public Attributes

static constexpr double DateTimeAtUnixStart = 25569.0
 UTC days since 30-Dec-1899 UTC, fractional part represents ratio of day. More...
 

Constructor & Destructor Documentation

◆ UTCTime() [1/3]

UTCTime::UTCTime ( int32_t  hours,
int32_t  minutes,
double  seconds,
int32_t  day,
int32_t  month,
int32_t  year 
)
noexcept

Constructs UTCTime from human readable time and date, parameters over their limits are handled and corrected unless the time passed is earlier than the start of unix time.

In that case time is set to zero unix time 00:00:00.00 1. 1. 1970.

Parameters
hoursinteger value of hours, usually in interval [0, 23]
minutesinteger value of minutes, usually in interval [0, 59]
secondsreal number of seconds, usually in interval [0.0, 60.0)
dayinteger number of day in month, first day starts at 1
monthinteger number of month in year, 1 for January and 12 for December
yearinteger number of years of Common Era [1970, INF)

◆ UTCTime() [2/3]

UTCTime::UTCTime ( int64_t  unixTime,
double  secondsFraction 
)
noexcept

Constructs UTCTime from unix time seconds and seconds fraction.

Fractional second values either negative or above absolute 1.0 are handled. If the time passed is earlier than the start of unix time UTCTime is going to be set to zero unix time 00:00:00.00 1. 1. 1970.

Parameters
unixTimeseconds since unix time start
secondsFractionfractional part of current second

◆ UTCTime() [3/3]

UTCTime::UTCTime ( double  dateTime)
explicitnoexcept

Constructs GPSTimeUTC from Delphi TDateTime value which is defined as double type.

It is equal to number of days since 30-Dec-1899 UTC. Fractional part is defined as ratio of day. If the time passed is earlier than the start of unix time UTCTime is going to be set to zero unix time 00:00:00.00 1. 1. 1970.

Parameters
dateTimevalue of days since 30-Dec-1899 UTC.

Member Function Documentation

◆ getDateTimeValue()

double UTCTime::getDateTimeValue ( ) const

UTC days since 30-Dec-1899 UTC, fractional part represents ratio of day.

Returns
number of days

◆ getDay()

int32_t UTCTime::getDay ( ) const

Day of month [1, 31].

Returns
day of month

◆ getHours()

int32_t UTCTime::getHours ( ) const

Hours of day [0, 23].

Returns
hours of day

◆ getMinutes()

int32_t UTCTime::getMinutes ( ) const

Minutes of hour [0, 59].

Returns
minutes of hour

◆ getMonth()

int32_t UTCTime::getMonth ( ) const

Month of year [1, 12].

Returns
month of year

◆ getSeconds()

int32_t UTCTime::getSeconds ( ) const

Seconds of minute with fractional part [0, 59].

Returns
seconds of minute

◆ getSecondsFraction()

double UTCTime::getSecondsFraction ( ) const

Fractional part of a second [0.0, 1.0)

Returns
fractional part of a second

◆ getUnixTimeValue()

int64_t UTCTime::getUnixTimeValue ( ) const

Integer number of seconds since start of Unix time on 01-Jan-1970 UTC.

Returns
integer number of UTC seconds

◆ getYear()

int32_t UTCTime::getYear ( ) const

Years of Common Era [1970, INF)

Returns
years CE

◆ IncrementSeconds()

static UTCTime UTCTime::IncrementSeconds ( const UTCTime &  time,
double  secondsIncrement 
)
static

Increments UTC time by positive or negative amount of seconds, the maximum size of an increment is equal to max int32 - 60 (approx.

68 years)

Returns
UTC time incremented by seconds
Exceptions
InvalidUTCTimeErrorif the resulting time would be earlier than unix time at 00:00:00 1st January 1970

◆ RelativeSecondsBetween()

static double UTCTime::RelativeSecondsBetween ( const UTCTime &  start,
const UTCTime &  end 
)
static

Calculates relative seconds between two UTC times.

Returns
seconds between two UTC times

Member Data Documentation

◆ DateTimeAtUnixStart

constexpr double UTCTime::DateTimeAtUnixStart = 25569.0
static

UTC days since 30-Dec-1899 UTC, fractional part represents ratio of day.

Returns
number of days First UTC date time that's not rejected.

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