CONZEPT 16 C++ API
C16::Value::Time Class Reference

Point in time relative to midnight (00:00) of a day. More...

#include "C16/Value/Time.hpp"

Detailed Description

Point in time relative to midnight (00:00) of a day.

Static Public Attributes

static const Time EMPTY
 Empty time (00:00:00). More...
 
static const Time MINIMUM
 Minimum time (00:00:00). More...
 
static const Time MAXIMUM
 Maximum time (23:59:59.99). More...
 

Static Public Member Functions

static Time now ()
 Gets the current time (UTC) of the system. More...
 
static Time now_local ()
 Gets the current time of the local timezone of the system. More...
 
static bool validate (int hours, int minutes, int seconds=0, int centiseconds=0)
 Validates a time by means of its hours, minutes, seconds and centiseconds since midnight (00:00). More...
 
static bool validate (long int serial)
 Validates a time by means of its serial in units of centiseconds since midnight (00:00). More...
 
static void validate_throw (int hours, int minutes, int seconds=0, int centiseconds=0)
 Validates a time by means of its hours, minutes, seconds and centiseconds since midnight (00:00). More...
 
static void validate_throw (long int serial)
 Validates a time by means of its serial in units of centiseconds since midnight (00:00). More...
 

Public Member Functions

 Time ()
 Constructs a zeroed time. More...
 
 Time (bool empty)
 Constructs a zeroed or an empty time. More...
 
 Time (int hours, int minutes, int seconds=0, int centiseconds=0)
 Constructs a time by means of its hours, minutes, seconds and centiseconds. More...
 
 Time (long int serial)
 Constructs a time by means of a serial in units of centiseconds since midnight (00:00). More...
 
 Time (const Time &other)
 Constructs a time by copying another time. More...
 
Timeoperator= (const Time &other)
 Assigns the time from another time. More...
 
int compare (const Time &other) const
 Compares the time with another time. More...
 
bool operator== (const Time &other) const
 Gets if the time is equal to another time. More...
 
bool operator!= (const Time &other) const
 Gets if the time is unequal to another time. More...
 
bool operator< (const Time &other) const
 Gets if the time is earlier than another time. More...
 
bool operator<= (const Time &other) const
 Gets if the time is equal to or earlier than another time. More...
 
bool operator>= (const Time &other) const
 Gets if the time is equal to or later than another time. More...
 
bool operator> (const Time &other) const
 Gets if the time is later than another time. More...
 
bool empty () const
 Gets if the time is empty. More...
 
int hours () const
 Gets the hours of the time. More...
 
int minutes () const
 Gets the minutes of the time since the last hour. More...
 
int seconds () const
 Gets the seconds of the time since the last minute. More...
 
int centiseconds () const
 Gets the centiseconds of the time since the last second. More...
 
int milliseconds () const
 Gets the milliseconds of the time since the last second. More...
 
long int serial () const
 Gets the serial of the time in units of centiseconds since midnight (00:00). More...
 
void clear (bool empty=false)
 Zeros or empties the time. More...
 
void assign (int hours, int minutes, int seconds=0, int centiseconds=0)
 Assigns the time by means of its hours, minutes, seconds and centiseconds since midnight (00:00). More...
 
void assign (long int serial)
 Assigns the time by means of its serial in units of centiseconds since midnight (00:00). More...
 

Member Data Documentation

◆ EMPTY

const Time C16::Value::Time::EMPTY
static

Empty time (00:00:00).

◆ MINIMUM

const Time C16::Value::Time::MINIMUM
static

Minimum time (00:00:00).

◆ MAXIMUM

const Time C16::Value::Time::MAXIMUM
static

Maximum time (23:59:59.99).

Constructor & Destructor Documentation

◆ Time() [1/5]

C16::Value::Time::Time ( )

Constructs a zeroed time.

◆ Time() [2/5]

C16::Value::Time::Time ( bool  empty)
explicit

Constructs a zeroed or an empty time.

Parameters
emptyConstruct an empty time

◆ Time() [3/5]

C16::Value::Time::Time ( int  hours,
int  minutes,
int  seconds = 0,
int  centiseconds = 0 
)

Constructs a time by means of its hours, minutes, seconds and centiseconds.

Parameters
hoursHours of the time (0 to 23)
minutesMinutes of the time since the last hour (0 to 59)
secondsSeconds of the time since the last minute (0 to 59)
centisecondsCentiseconds of the time since the last second (0 to 99)
Exceptions
Exception::InvalidityHours invalid.
Exception::InvalidityMinutes invalid.
Exception::InvaliditySeconds invalid.
Exception::InvalidityCentiseconds invalid.

◆ Time() [4/5]

C16::Value::Time::Time ( long int  serial)
explicit

Constructs a time by means of a serial in units of centiseconds since midnight (00:00).

Parameters
serialSerial of the time (0 to MAXIMUM.serial())
Exceptions
Exception::InvaliditySerial invalid.

◆ Time() [5/5]

C16::Value::Time::Time ( const Time other)

Constructs a time by copying another time.

Parameters
otherAnother time

Member Function Documentation

◆ now()

static Time C16::Value::Time::now ( )
static

Gets the current time (UTC) of the system.

◆ now_local()

static Time C16::Value::Time::now_local ( )
static

Gets the current time of the local timezone of the system.

◆ validate() [1/2]

static bool C16::Value::Time::validate ( int  hours,
int  minutes,
int  seconds = 0,
int  centiseconds = 0 
)
static

Validates a time by means of its hours, minutes, seconds and centiseconds since midnight (00:00).

Parameters
hoursHours of the time (0 to 23)
minutesMinutes of the time since the last hour (0 to 59)
secondsSeconds of the time since the last minute (0 to 59)
centisecondsCentiseconds of the time since the last second (0 to 99)
Returns
Validity of the time

◆ validate() [2/2]

static bool C16::Value::Time::validate ( long int  serial)
static

Validates a time by means of its serial in units of centiseconds since midnight (00:00).

Parameters
serialSerial of the time (0 to MAXIMUM.serial())
Returns
Validity of the time

◆ validate_throw() [1/2]

static void C16::Value::Time::validate_throw ( int  hours,
int  minutes,
int  seconds = 0,
int  centiseconds = 0 
)
static

Validates a time by means of its hours, minutes, seconds and centiseconds since midnight (00:00).

Parameters
hoursHours of the time (0 to 23)
minutesMinutes of the time since the last hour (0 to 59)
secondsSeconds of the time since the last minute (0 to 59)
centisecondsCentiseconds of the time since the last second (0 to 99)
Exceptions
Exception::InvalidityHours invalid.
Exception::InvalidityMinutes invalid.
Exception::InvaliditySeconds invalid.
Exception::InvalidityCentiseconds invalid.

◆ validate_throw() [2/2]

static void C16::Value::Time::validate_throw ( long int  serial)
static

Validates a time by means of its serial in units of centiseconds since midnight (00:00).

Parameters
serialSerial of the time (0 to MAXIMUM.serial())
Exceptions
Exception::InvaliditySerial invalid.

◆ operator=()

Time& C16::Value::Time::operator= ( const Time other)

Assigns the time from another time.

Parameters
otherAnother time
Returns
This time

◆ compare()

int C16::Value::Time::compare ( const Time other) const

Compares the time with another time.

Parameters
otherAnother time
Returns
Difference of the times
Return values
0The time is equal to the other time.
< 0The time is earlier than the other time.
> 0The time is later than the other time.

◆ operator==()

bool C16::Value::Time::operator== ( const Time other) const

Gets if the time is equal to another time.

Parameters
otherAnother time

◆ operator!=()

bool C16::Value::Time::operator!= ( const Time other) const

Gets if the time is unequal to another time.

Parameters
otherAnother time

◆ operator<()

bool C16::Value::Time::operator< ( const Time other) const

Gets if the time is earlier than another time.

Parameters
otherAnother time

◆ operator<=()

bool C16::Value::Time::operator<= ( const Time other) const

Gets if the time is equal to or earlier than another time.

Parameters
otherAnother time

◆ operator>=()

bool C16::Value::Time::operator>= ( const Time other) const

Gets if the time is equal to or later than another time.

Parameters
otherAnother time

◆ operator>()

bool C16::Value::Time::operator> ( const Time other) const

Gets if the time is later than another time.

Parameters
otherAnother time

◆ empty()

bool C16::Value::Time::empty ( ) const

Gets if the time is empty.

◆ hours()

int C16::Value::Time::hours ( ) const

Gets the hours of the time.

Note
Returns 0 if empty.

◆ minutes()

int C16::Value::Time::minutes ( ) const

Gets the minutes of the time since the last hour.

Note
Returns 0 if empty.

◆ seconds()

int C16::Value::Time::seconds ( ) const

Gets the seconds of the time since the last minute.

Note
Returns 0 if empty.

◆ centiseconds()

int C16::Value::Time::centiseconds ( ) const

Gets the centiseconds of the time since the last second.

Note
Returns 0 if empty.

◆ milliseconds()

int C16::Value::Time::milliseconds ( ) const

Gets the milliseconds of the time since the last second.

Note
Returns 0 if empty.

◆ serial()

long int C16::Value::Time::serial ( ) const

Gets the serial of the time in units of centiseconds since midnight (00:00).

Note
Returns 0 if empty.

◆ clear()

void C16::Value::Time::clear ( bool  empty = false)

Zeros or empties the time.

Parameters
emptyEmpty the time

◆ assign() [1/2]

void C16::Value::Time::assign ( int  hours,
int  minutes,
int  seconds = 0,
int  centiseconds = 0 
)

Assigns the time by means of its hours, minutes, seconds and centiseconds since midnight (00:00).

Parameters
hoursHours of the time (0 to 23)
minutesMinutes of the time since the last hour (0 to 59)
secondsSeconds of the time since the last minute (0 to 59)
centisecondsCentiseconds of the time since the last second (0 to 99)
Exceptions
Exception::InvalidityHours invalid.
Exception::InvalidityMinutes invalid.
Exception::InvaliditySeconds invalid.
Exception::InvalidityCentiseconds invalid.

◆ assign() [2/2]

void C16::Value::Time::assign ( long int  serial)

Assigns the time by means of its serial in units of centiseconds since midnight (00:00).

Parameters
serialSerial of the time (0 to MAXIMUM.serial())
Exceptions
Exception::InvaliditySerial invalid.