time_and_date


The os_time_and_date class represents a point in time in a particular time zone between 00:00 Jan 1, 4713 b.c. and 23:59 Dec 31, 32766 a.d. In the event of specifying a local time, if that time falls within the range of duplicate times caused by DST adjustments, then that time will be interpreted as having occurred after the DST adjustment.

Library

Time<ToolKit>

Declaration

#include <ospace/time/timedate.h>

class os_time_and_date

Typedefs and Enums

See catalog entries for os_time and os_date .

Interface

Constructor
os_time_and_date ()
Constructs a date and time of Jan 1, 1970, 00:00:00.
Constructor
os_time_and_date( const os_time_period& period )
Constructs a time and date from period , which represents the number of seconds since 00:00:00 Jan 1, 1970 UTC.
Constructor
os_time_and_date( const os_time_period& period , const os_date& date )
Constructs a time and date from period , which represents the number of seconds since date , interpreted as a local time.
Constructor
os_time_and_date( const tm& tms , os_usecond_t microseconds )
Constructs a time and date from the tm structure tms and microseconds (default 0), interpreted as a local time.
Constructor
os_time_and_date( const time_t seconds )
Constructs a time and date from the time_t value seconds , which represents the number of seconds since 00:00:00 Jan 1, 1970 UTC.
Constructor
os_time_and_date( const os_time& time , const os_date& date )
Constructs a time and date of date date , time time , and default time zone, interpreted as a local time.
Constructor
os_time_and_date( const os_time& time , const os_date& date , const os_time_zone& tzone )
Constructs a time and date of date date , time time, and time zone tzone , interpreted as a local time.
Constructor
os_time_and_date( const os_time_and_date& time_and_date )
Constructs a copy of time_and_date .
!=
bool operator!=( const os_time_and_date& time_and_date ) const
Returns true if time and date are not equal to time_and_date .
+
os_time_and_date operator+( const os_time_period& period ) const
Returns time and date added to period .
+=
os_time_and_date& operator+=( const os_time_period& period )
Adds period to time and date and returns the new time and date value.
-
os_time_period operator-( const os_time_and_date& time_and_date ) const
Returns the period between time and date and time_and_date .
-
os_time_and_date operator-( const os_time_period& period ) const
Returns period subtracted from time and date.
-=
os_time_and_date& operator-=( const os_time_period& period )
Subtracts period from time and date and returns the new time and date value.
<
bool operator<( const os_time_and_date& time_and_date ) const
Returns true if time and date are earlier than time_and_date .
<=
bool operator<=( const os_time_and_date& time_and_date ) const
Returns true if time and date are earlier than or equal to time_and_date .
=
os_time_and_date& operator=( const os_time_and_date& time_and_date )
Assigns time_and_date to time and date.
=
os_time_and_date& operator=( const tm& tm_struct )
Assigns tm_struct to time and date.
==
bool operator==( const os_time_and_date& time_and_date ) const
Returns true if time and date are equal to time_and_date .
>
bool operator>( const os_time_and_date& time_and_date ) const
Returns true if time and date are later than time_and_date .
>=
bool operator>=( const os_time_and_date& time_and_date ) const
Returns true if time and date are later than or equal to time_and_date .
(tm)
operator tm() const
Returns time and date encoded as a tm structure.
date
os_date date() const
Returns the date.
date
void date( const os_date& date )
Sets the date to date .
default_format
/* static */ string default_format()
Returns the default format. [not MTSAFE]
default_format
/* static */ void default_format( const string& format )
Sets the default format to format . [not MTSAFE]
default_time_zone
/* static */ void default_time_zone( const os_time_zone& zone )
Sets the default time zone to zone .
default_time_zone
/* static */ const os_time_zone& default_time_zone()
Returns a pointer to the default time zone.
initialize_statics
/* static */ void initialize_statics( enum Encoding enc = Ascii )
Initialization for time. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
insert
/* static */ bool insert( os_time_zone* zone )
Inserts the time zone zone into a static map of custom time zones and returns true if the time zone name is not already inserted and false otherwise. The custom time zone zone becomes the default time zone if the time zone's name matches tzname[ 0 ].
is_dst
bool is_dst() const
Returns true if daylight savings time is in effect.
max_date
/* static */ const os_date& max_date()
Returns the maximum date value.
max_time
/* static */ const os_time& max_time()
Returns the maximum time value.
min_date
/* static */ const os_date& min_date()
Returns the minimum date value.
min_time
/* static */ const os_time& min_time()
Returns the minimum time value.
now
/* static */ os_time_and_date now()
Returns the current local time and date.

Throws: os_time_toolkit_error

print
void print( ostream& stream ) const
Prints to stream .
std_date
os_date std_date() const
Returns the standard date.
std_time
os_time std_time() const
Returns the standard time.
time
void time( const os_time& time )
Sets time to time .
time
os_time time() const
Returns current local time.
time_and_date
void time_and_date( const time_t seconds )
Sets time and date to seconds seconds after 00:00:00 Jan 1, 1970 UTC.
time_and_date
void time_and_date( const os_time_period& period , const os_date& date )
Sets time and date to period after date .
time_and_date
void time_and_date( const os_time& time , const os_date& date )
Sets date to date and time to time .
time_and_date
void time_and_date( const os_time_period& period )
Sets time and date from the time that is (00:00:00.0, Jan 1, 1970 a.d. + period ).
time_and_date
void time_and_date( const tm& tm_struct , os_usecond_t microseconds )
Sets time and date from the tm structure tm_struct and microseconds (default 0).
time_and_date
void time_and_date( const os_time& time , const os_date& date , const os_time_zone& tzone )
Sets date to date , time to time, and time zone to tzone .
time_zone
void time_zone( const os_time_zone& tzone )
Sets time zone to tzone .
time_zone
const os_time_zone& time_zone() const
Returns a pointer to time zone.
utc_date
os_date utc_date() const
Returns universal time coordinates (utc) date.
utc_time
os_time utc_time() const
Returns utc time.
utc_time_and_date
void utc_time_and_date( const os_time& time , const os_date& date )
Sets date to date and time to time .
utc_time_and_date
os_time_period utc_time_and_date() const
Returns a time period representing the current time and date in seconds since midnight, January 1, 4713 b.c.

Non-Member Functions

+
os_time_and_date operator+( const os_time_period& period , const os_time_and_date& time_and_date )
Returns time_and_date added to period .
+
os_time_and_date operator+( const os_time_period& period , const os_time_and_date& time_and_date );
Returns period added to time_and_date .
<<
ostream& operator<<( ostream& stream , const os_time_and_date& time_and_date )
Prints time_and_date to stream using the current format.

Universal Streaming Service

#include <ospace/uss/time.h>

<<
os_bstream& operator<<( os_bstream& stream , const os_time_and_date& time_and_date )
Writes time_and_date to stream .
>>
os_bstream& operator>>( os_bstream& stream , os_time_and_date& time_and_date )
Reads time_and_date from stream .

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