time


Represents a time between 00:00:00 and 23:59:59, inclusive, to microsecond accuracy. Time arithmetic wraps around within this range.

Library

Time<ToolKit>

Declaration

#include <ospace/time/time.h>

class os_time

Typedefs

typedef unsigned short os_hour_t;
typedef unsigned short os_minute_t;
typedef unsigned short os_second_t;
typedef unsigned long  os_usecond_t;
  

Interface

Constructor
os_time()
Constructs a time that represents midnight (00:00:00).
Constructor
os_time( long seconds )
Constructs a time that represents seconds past midnight.
Constructor
os_time( os_hour_t hour , os_minute_t minute , os_second_t second , os_usecond_t microsecond )
Constructs a time that represents hour , minute , second (default 0 ) and microsecond (default 0 ) since midnight.

Throws: os_time_toolkit_error

Constructor
os_time( const os_time_period& period )
Constructs a time that represents period after midnight.
Constructor
os_time( const tm& value , os_usecond_t microsecond )
Constructs a time encoded by the tm structure value and microsecond (default 0 ) .
Constructor
os_time( const os_time& time )
Constructs a copy of time .
!=
bool operator!=( const os_time& time ) const
Returns true if time is not equal to time .
+
os_time operator+( const os_time_period& period ) const
Returns time added to period .
+=
os_time& operator+=( const os_time_period& period )
Adds period to time and returns the new time.
-
os_time operator-( const os_time_period& period ) const
Returns period subtracted from time.
-
os_time_period operator-( const os_time& time ) const
Returns the period between time and time .
-=
os_time& operator-=( const os_time_period& period )
Subtracts period from time and returns the new time.
<
bool operator<( const os_time& time ) const
Returns true if time is earlier than time .
<=
bool operator<=( const os_time& time ) const
Returns true if time is earlier than or equal to time .
=
os_time& operator=( const os_time& time )
Assigns time to time.
==
bool operator==( const os_time& time ) const
Returns true if time equals time .
>
bool operator>( const os_time& time ) const
Returns true if time is later than time .
>=
bool operator>=( const os_time& time ) const
Returns true if time is later than or equal to time .
am_name
/* static */ const string& am_name()
Returns the string used to denote times before noon.
am_name
/* static */ void am_name( const string& am )
Sets the string used to denote times before noon to am . [not MTSAFE]
default_format
/* static */ void default_format( const string& format )
Sets the default format to format . [not MTSAFE]
default_format
/* static */ string default_format()
Returns the default format.
hours
os_hour_t hours() const
Returns the hours field (0-23).
is_am
bool is_am() const
Returns true if time is before noon.
is_hour
/* static */ bool is_hour( os_hour_t hour )
Returns true if hour is a valid hour (0-23).
is_microsecond
/* static */ bool is_microsecond( os_usecond_t microsecond )
Returns true if microsecond is a valid microsecond. A microsecond for an os_time must be non-negative, unlike one for an os_time_period .
is_minute
/* static */ bool is_minute( os_minute_t minute )
Returns true if minute is a valid minute (0-59).
is_pm
bool is_pm() const
Returns true if time is after noon.
is_second
/* static */ bool is_second( os_second_t second )
Returns true if second is a valid second (0-59).
max_time
/* static */ const os_time& max_time()
Returns the maximum time value.
microseconds
os_usecond_t microseconds() const
Returns the microseconds field (0-999999).
min_time
/* static */ const os_time& min_time()
Returns the minimum time value.
minutes
os_minute_t minutes() const
Returns the minutes field (0-59).
now
/* static */ os_time now()
Returns the current local time.
(os_time_period)
operator os_time_period() const
Returns time as the period of seconds since midnight.
pm_name
/* static */ void pm_name( const string& pm )
Sets the string used to denote times after noon to pm . [not MTSAFE]
pm_name
/* static */ const string& pm_name()
Returns the string used to denote times after noon.
print
void print( ostream& stream ) const
Prints to stream .
seconds
os_second_t seconds() const
Returns the seconds field (0-59).
time
void time( const tm& value , os_usecond_t microsecond )
Sets the time from the tm structure value and microsecond (default 0 ) . All fields except tm_sec , tm_min , and tm_hour are cleared and ignored.
time
void time( os_hour_t hour , os_minute_t minute , os_second_t second , os_usecond_t microsecond )
Sets the time to hour (0-23), minute (0-59), second (0-59) (default 0 )  and microsecond (0-999999) (default 0 ) .

Throws: os_time_toolkit_error

to_string
string to_string() const
Returns time as a formatted string using the default format.
to_string
string to_string( const string& format ) const
Returns time as a formatted string using format .

Non-Member Functions

<<
ostream& operator<<( ostream& stream , const os_time& time )
Prints time to stream using the current format.

Universal Streaming Service

#include <ospace/uss/time.h>

<<
os_bstream& operator<<( os_bstream& stream , const os_time& time )
Writes time to stream .
>>
os_bstream& operator>>( os_bstream& stream , os_time& time )
Reads time from stream .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.