Present  0.9
 All Classes Files Functions Variables Typedefs Friends Macros Pages
Timestamp Struct Reference

Class or struct representing an exact point in time. More...

Public Member Functions

time_t get_time_t () const
 Convert a Timestamp to a "time_t" (from C's time library). More...
 
struct tm get_struct_tm (const TimeDelta &time_zone_offset) const
 Convert a Timestamp to a "struct tm" (from C's time library) in a certain time zone (represented by an offset from UTC). More...
 
struct tm get_struct_tm_utc () const
 Convert a Timestamp to a "struct tm" (from C's time library) in Coordinated Universal Time. More...
 
struct tm get_struct_tm_local () const
 Convert a Timestamp to a "struct tm" (from C's time library) in the system's current local time zone. More...
 
Date get_date (const TimeDelta &time_zone_offset) const
 Get the Date component of a Timestamp in a certain time zone (represented by an offset from UTC). More...
 
Date get_date_utc () const
 Get the Date component of a Timestamp in Coordinated Universal Time. More...
 
Date get_date_local () const
 Get the Date component of a Timestamp in the system's current local time zone. More...
 
ClockTime get_clock_time (const TimeDelta &time_zone_offset) const
 Get the ClockTime component of a Timestamp in a certain time zone (represented by an offset from UTC). More...
 
ClockTime get_clock_time_utc () const
 Get the ClockTime component of a Timestamp in Coordinated Universal Time. More...
 
ClockTime get_clock_time_local () const
 Get the ClockTime component of a Timestamp in the system's current local time zone. More...
 
TimeDelta difference (const Timestamp &other) const
 Get the difference between two Timestamp instances as a TimeDelta. More...
 
TimeDelta absolute_difference (const Timestamp &other) const
 Get the absolute difference between two Timestamp instances as a TimeDelta. More...
 
Timestampoperator+= (const TimeDelta &delta)
 Add a TimeDelta to a Timestamp. More...
 
Timestampoperator+= (const DayDelta &delta)
 Add a DayDelta to a Timestamp. More...
 
Timestampoperator+= (const MonthDelta &delta)
 Add a MonthDelta to a Timestamp. More...
 
Timestampoperator-= (const TimeDelta &delta)
 Subtract a TimeDelta from a Timestamp. More...
 
Timestampoperator-= (const DayDelta &delta)
 Subtract a DayDelta from a Timestamp. More...
 
Timestampoperator-= (const MonthDelta &delta)
 Subtract a MonthDelta from a Timestamp. More...
 

Static Public Member Functions

static Timestamp create (const time_t time)
 Create a new Timestamp based on a "time_t" value (from C's time library). More...
 
static Timestamp create (const struct tm &tm, const TimeDelta &time_zone_offset)
 Create a new Timestamp based on a "struct tm" value (from C's time library) in a certain time zone. More...
 
static Timestamp create_utc (const struct tm &tm)
 Create a new Timestamp based on a "struct tm" value (from C's time library) in Coordinated Universal Time. More...
 
static Timestamp create_local (const struct tm &tm)
 Create a new Timestamp based on a "struct tm" value (from C's time library) in the system's current local time zone. More...
 
static Timestamp create (const Date &date, const ClockTime &clock_time, const TimeDelta &time_zone_offset)
 Create a new Timestamp based on a Date and ClockTime in a certain time zone. More...
 
static Timestamp create_utc (const Date &date, const ClockTime &clock_time)
 Create a new Timestamp based on a Date and ClockTime in Coordinated Universal Time. More...
 
static Timestamp create_local (const Date &date, const ClockTime &clock_time)
 Create a new Timestamp based on a Date and ClockTime in the system's current local time zone. More...
 
static Timestamp now ()
 Create a new Timestamp representing the exact time right now. More...
 
static Timestamp epoch ()
 Create a new Timestamp representing the UNIX epoch (Jan. More...
 
static short compare (const Timestamp &lhs, const Timestamp &rhs)
 Compare two Timestamp instances. More...
 

Public Attributes

present_bool has_error
 This will be true if there were any errors when creating this Timestamp. More...
 
struct {
   unsigned int   invalid_clock_time: 1
 
   unsigned int   invalid_date: 1
 
errors
 If there were any errors when creating this Timestamp, then one or more of these fields will be set. More...
 
struct PresentTimestampData data_
 

Friends

const Timestamp operator+ (const Timestamp &lhs, const TimeDelta &rhs)
 
const Timestamp operator+ (const TimeDelta &lhs, const Timestamp &rhs)
 
const Timestamp operator+ (const Timestamp &lhs, const DayDelta &rhs)
 
const Timestamp operator+ (const DayDelta &lhs, const Timestamp &rhs)
 
const Timestamp operator+ (const Timestamp &lhs, const MonthDelta &rhs)
 
const Timestamp operator+ (const MonthDelta &lhs, const Timestamp &rhs)
 
const Timestamp operator- (const Timestamp &lhs, const TimeDelta &rhs)
 
const Timestamp operator- (const Timestamp &lhs, const DayDelta &rhs)
 
const Timestamp operator- (const Timestamp &lhs, const MonthDelta &rhs)
 
bool operator== (const Timestamp &lhs, const Timestamp &rhs)
 Determine whether two Timestamp instances represent the exact same point in time (lhs == rhs). More...
 
bool operator!= (const Timestamp &lhs, const Timestamp &rhs)
 
bool operator< (const Timestamp &lhs, const Timestamp &rhs)
 Determine whether a Timestamp occurs earlier than another Timestamp (lhs < rhs). More...
 
bool operator<= (const Timestamp &lhs, const Timestamp &rhs)
 Determine whether a Timestamp occurs earlier than or at the same time as another Timestamp (lhs <= rhs). More...
 
bool operator> (const Timestamp &lhs, const Timestamp &rhs)
 Determine whether a Timestamp occurs later than another Timestamp (lhs > rhs). More...
 
bool operator>= (const Timestamp &lhs, const Timestamp &rhs)
 Determine whether a Timestamp occurs later than or at the same time as another Timestamp (lhs >= rhs). More...
 

Detailed Description

Class or struct representing an exact point in time.

This includes a full date and time, and is sensitive to time zones.

Member Function Documentation

static Timestamp Timestamp::create ( const time_t  time)
static

Create a new Timestamp based on a "time_t" value (from C's time library).

Parameters
timeThe "time_t" value representing the timestamp.
static Timestamp Timestamp::create ( const struct tm &  tm,
const TimeDelta time_zone_offset 
)
static

Create a new Timestamp based on a "struct tm" value (from C's time library) in a certain time zone.

Parameters
tmThe "struct tm" value representing the date and time.
time_zone_offsetThe time zone offset (from UTC) used to interpret tm.
static Timestamp Timestamp::create_utc ( const struct tm &  tm)
static

Create a new Timestamp based on a "struct tm" value (from C's time library) in Coordinated Universal Time.

Parameters
tmThe "struct tm" value representing the date and time.
static Timestamp Timestamp::create_local ( const struct tm &  tm)
static

Create a new Timestamp based on a "struct tm" value (from C's time library) in the system's current local time zone.

Parameters
tmThe "struct tm" value representing the date and time.
static Timestamp Timestamp::create ( const Date date,
const ClockTime clock_time,
const TimeDelta time_zone_offset 
)
static

Create a new Timestamp based on a Date and ClockTime in a certain time zone.

Future modifications to the original Date and ClockTime do NOT affect the new Timestamp.

If the Date or ClockTime is invalid, the Timestamp will have has_error and errors set.

Attention
Make sure to check for any errors by checking if the has_error field on the returned struct is true.

If has_error is true, then at least one of the fields in the errors struct will also be true.

See Also
Timestamp::has_error
Timestamp::errors
Parameters
dateThe Date component of the Timestamp.
clock_timeThe ClockTime component of the Timestamp.
time_zone_offsetThe time zone offset (from UTC) used to interpret date and clockTime.
static Timestamp Timestamp::create_utc ( const Date date,
const ClockTime clock_time 
)
static

Create a new Timestamp based on a Date and ClockTime in Coordinated Universal Time.

Future modifications to the original Date and ClockTime do NOT affect the new Timestamp.

If the Date or ClockTime is invalid, the Timestamp will have has_error and errors set.

Attention
Make sure to check for any errors by checking if the has_error field on the returned struct is true.

If has_error is true, then at least one of the fields in the errors struct will also be true.

See Also
Timestamp::has_error
Timestamp::errors
Parameters
dateThe Date component of the Timestamp.
clock_timeThe ClockTime component of the Timestamp.
static Timestamp Timestamp::create_local ( const Date date,
const ClockTime clock_time 
)
static

Create a new Timestamp based on a Date and ClockTime in the system's current local time zone.

Future modifications to the original Date and ClockTime do NOT affect the new Timestamp.

If the Date or ClockTime is invalid, the Timestamp will have has_error and errors set.

Attention
Make sure to check for any errors by checking if the has_error field on the returned struct is true.

If has_error is true, then at least one of the fields in the errors struct will also be true.

See Also
Timestamp::has_error
Timestamp::errors
Parameters
dateThe Date component of the Timestamp.
clock_timeThe ClockTime component of the Timestamp.
static Timestamp Timestamp::now ( )
static

Create a new Timestamp representing the exact time right now.

On most POSIX systems, this will return a Timestamp with up to nanosecond precision (depending on the maximum precision of the machine). On other systems, the Timestamp will only be to the nearest second.

static Timestamp Timestamp::epoch ( )
static

Create a new Timestamp representing the UNIX epoch (Jan.

1, 1970 00:00:00 UTC).

time_t Timestamp::get_time_t ( ) const

Convert a Timestamp to a "time_t" (from C's time library).

struct tm Timestamp::get_struct_tm ( const TimeDelta time_zone_offset) const

Convert a Timestamp to a "struct tm" (from C's time library) in a certain time zone (represented by an offset from UTC).

struct tm Timestamp::get_struct_tm_utc ( ) const

Convert a Timestamp to a "struct tm" (from C's time library) in Coordinated Universal Time.

struct tm Timestamp::get_struct_tm_local ( ) const

Convert a Timestamp to a "struct tm" (from C's time library) in the system's current local time zone.

Date Timestamp::get_date ( const TimeDelta time_zone_offset) const

Get the Date component of a Timestamp in a certain time zone (represented by an offset from UTC).

Modifications to the returned Date do NOT affect the existing Timestamp.

Date Timestamp::get_date_utc ( ) const

Get the Date component of a Timestamp in Coordinated Universal Time.

Modifications to the returned Date do NOT affect the existing Timestamp.

Date Timestamp::get_date_local ( ) const

Get the Date component of a Timestamp in the system's current local time zone.

Modifications to the returned Date do NOT affect the existing Timestamp.

ClockTime Timestamp::get_clock_time ( const TimeDelta time_zone_offset) const

Get the ClockTime component of a Timestamp in a certain time zone (represented by an offset from UTC).

Modifications to the returned ClockTime do NOT affect the existing Timestamp.

ClockTime Timestamp::get_clock_time_utc ( ) const

Get the ClockTime component of a Timestamp in Coordinated Universal Time.

Modifications to the returned ClockTime do NOT affect the existing Timestamp.

ClockTime Timestamp::get_clock_time_local ( ) const

Get the ClockTime component of a Timestamp in the system's current local time zone.

Modifications to the returned ClockTime do NOT affect the existing Timestamp.

TimeDelta Timestamp::difference ( const Timestamp other) const

Get the difference between two Timestamp instances as a TimeDelta.

TimeDelta Timestamp::absolute_difference ( const Timestamp other) const

Get the absolute difference between two Timestamp instances as a TimeDelta.

Timestamp& Timestamp::operator+= ( const TimeDelta delta)

Add a TimeDelta to a Timestamp.

Timestamp& Timestamp::operator+= ( const DayDelta delta)

Add a DayDelta to a Timestamp.

Timestamp& Timestamp::operator+= ( const MonthDelta delta)

Add a MonthDelta to a Timestamp.

Timestamp& Timestamp::operator-= ( const TimeDelta delta)

Subtract a TimeDelta from a Timestamp.

Timestamp& Timestamp::operator-= ( const DayDelta delta)

Subtract a DayDelta from a Timestamp.

Timestamp& Timestamp::operator-= ( const MonthDelta delta)

Subtract a MonthDelta from a Timestamp.

static short Timestamp::compare ( const Timestamp lhs,
const Timestamp rhs 
)
static

Compare two Timestamp instances.

  • If lhs < rhs, then a negative integer will be returned.
  • If lhs == rhs, then 0 will be returned.
  • If lhs > rhs, then a positive integer will be returned.

Friends And Related Function Documentation

const Timestamp operator+ ( const Timestamp lhs,
const TimeDelta rhs 
)
friend
const Timestamp operator+ ( const TimeDelta lhs,
const Timestamp rhs 
)
friend
const Timestamp operator+ ( const Timestamp lhs,
const DayDelta rhs 
)
friend
const Timestamp operator+ ( const DayDelta lhs,
const Timestamp rhs 
)
friend
const Timestamp operator+ ( const Timestamp lhs,
const MonthDelta rhs 
)
friend
const Timestamp operator+ ( const MonthDelta lhs,
const Timestamp rhs 
)
friend
const Timestamp operator- ( const Timestamp lhs,
const TimeDelta rhs 
)
friend
const Timestamp operator- ( const Timestamp lhs,
const DayDelta rhs 
)
friend
const Timestamp operator- ( const Timestamp lhs,
const MonthDelta rhs 
)
friend
bool operator== ( const Timestamp lhs,
const Timestamp rhs 
)
friend

Determine whether two Timestamp instances represent the exact same point in time (lhs == rhs).

bool operator!= ( const Timestamp lhs,
const Timestamp rhs 
)
friend
bool operator< ( const Timestamp lhs,
const Timestamp rhs 
)
friend

Determine whether a Timestamp occurs earlier than another Timestamp (lhs < rhs).

bool operator<= ( const Timestamp lhs,
const Timestamp rhs 
)
friend

Determine whether a Timestamp occurs earlier than or at the same time as another Timestamp (lhs <= rhs).

bool operator> ( const Timestamp lhs,
const Timestamp rhs 
)
friend

Determine whether a Timestamp occurs later than another Timestamp (lhs > rhs).

bool operator>= ( const Timestamp lhs,
const Timestamp rhs 
)
friend

Determine whether a Timestamp occurs later than or at the same time as another Timestamp (lhs >= rhs).

Member Data Documentation

present_bool Timestamp::has_error

This will be true if there were any errors when creating this Timestamp.

For more details about the errors that occurred, see errors. For more details about the errors that occurred, see errors.

This field should be treated as read-only; DO NOT modify its contents!

unsigned int Timestamp::invalid_clock_time
unsigned int Timestamp::invalid_date
struct { ... } Timestamp::errors

If there were any errors when creating this Timestamp, then one or more of these fields will be set.

To quickly check if any error occurred, see has_error. To quickly check if any error occurred, see has_error.

These fields should be treated as read-only; DO NOT modify their contents!

struct PresentTimestampData Timestamp::data_

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