Present  0.9
 All Classes Files Functions Variables Typedefs Friends Macros Pages
timestamp.h File Reference

Go to the source code of this file.

Classes

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

Functions

struct Timestamp Timestamp_from_time_t (const time_t time)
 Create a new Timestamp based on a "time_t" value (from C's time library). More...
 
void Timestamp_ptr_from_time_t (struct Timestamp *const result, const time_t time)
 Create a new Timestamp based on a "time_t" value (from C's time library). More...
 
struct Timestamp Timestamp_from_struct_tm (const struct tm tm, const struct TimeDelta *const time_zone_offset)
 Create a new Timestamp based on a "struct tm" value (from C's time library) in a certain time zone. More...
 
void Timestamp_ptr_from_struct_tm (struct Timestamp *const result, const struct tm tm, const struct TimeDelta *const time_zone_offset)
 Create a new Timestamp based on a "struct tm" value (from C's time library) in a certain time zone. More...
 
struct Timestamp Timestamp_from_struct_tm_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...
 
void Timestamp_ptr_from_struct_tm_utc (struct Timestamp *const result, const struct tm tm)
 Create a new Timestamp based on a "struct tm" value (from C's time library) in Coordinated Universal Time. More...
 
struct Timestamp Timestamp_from_struct_tm_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...
 
void Timestamp_ptr_from_struct_tm_local (struct Timestamp *const result, 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...
 
struct Timestamp Timestamp_create (const struct Date *const date, const struct ClockTime *const clock_time, const struct TimeDelta *const time_zone_offset)
 Create a new Timestamp based on a Date and ClockTime in a certain time zone. More...
 
void Timestamp_ptr_create (struct Timestamp *const result, const struct Date *const date, const struct ClockTime *const clock_time, const struct TimeDelta *const time_zone_offset)
 Create a new Timestamp based on a Date and ClockTime in a certain time zone. More...
 
struct Timestamp Timestamp_create_utc (const struct Date *const date, const struct ClockTime *const clock_time)
 Create a new Timestamp based on a Date and ClockTime in Coordinated Universal Time. More...
 
void Timestamp_ptr_create_utc (struct Timestamp *const result, const struct Date *const date, const struct ClockTime *const clock_time)
 Create a new Timestamp based on a Date and ClockTime in Coordinated Universal Time. More...
 
struct Timestamp Timestamp_create_local (const struct Date *const date, const struct ClockTime *const clock_time)
 Create a new Timestamp based on a Date and ClockTime in the system's current local time zone. More...
 
void Timestamp_ptr_create_local (struct Timestamp *const result, const struct Date *const date, const struct ClockTime *const clock_time)
 Create a new Timestamp based on a Date and ClockTime in the system's current local time zone. More...
 
struct Timestamp Timestamp_now (void)
 Create a new Timestamp representing the exact time right now. More...
 
void Timestamp_ptr_now (struct Timestamp *const result)
 Create a new Timestamp representing the exact time right now. More...
 
struct Timestamp Timestamp_epoch (void)
 Create a new Timestamp representing the UNIX epoch (Jan. More...
 
void Timestamp_ptr_epoch (struct Timestamp *const result)
 Create a new Timestamp representing the UNIX epoch (Jan. More...
 
time_t Timestamp_get_time_t (const struct Timestamp *const self)
 Convert a Timestamp to a "time_t" (from C's time library). More...
 
struct tm Timestamp_get_struct_tm (const struct Timestamp *const self, const struct TimeDelta *const time_zone_offset)
 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 Timestamp_get_struct_tm_utc (const struct Timestamp *const self)
 Convert a Timestamp to a "struct tm" (from C's time library) in Coordinated Universal Time. More...
 
struct tm Timestamp_get_struct_tm_local (const struct Timestamp *const self)
 Convert a Timestamp to a "struct tm" (from C's time library) in the system's current local time zone. More...
 
struct Date Timestamp_get_date (const struct Timestamp *const self, const struct TimeDelta *const time_zone_offset)
 Get the Date component of a Timestamp in a certain time zone (represented by an offset from UTC). More...
 
struct Date Timestamp_get_date_utc (const struct Timestamp *const self)
 Get the Date component of a Timestamp in Coordinated Universal Time. More...
 
struct Date Timestamp_get_date_local (const struct Timestamp *const self)
 Get the Date component of a Timestamp in the system's current local time zone. More...
 
struct ClockTime Timestamp_get_clock_time (const struct Timestamp *const self, const struct TimeDelta *const time_zone_offset)
 Get the ClockTime component of a Timestamp in a certain time zone (represented by an offset from UTC). More...
 
struct ClockTime Timestamp_get_clock_time_utc (const struct Timestamp *const self)
 Get the ClockTime component of a Timestamp in Coordinated Universal Time. More...
 
struct ClockTime Timestamp_get_clock_time_local (const struct Timestamp *const self)
 Get the ClockTime component of a Timestamp in the system's current local time zone. More...
 
struct TimeDelta Timestamp_difference (const struct Timestamp *const self, const struct Timestamp *const other)
 Get the difference between two Timestamp instances as a TimeDelta. More...
 
struct TimeDelta Timestamp_absolute_difference (const struct Timestamp *const self, const struct Timestamp *const other)
 Get the absolute difference between two Timestamp instances as a TimeDelta. More...
 
void Timestamp_add_TimeDelta (struct Timestamp *const self, const struct TimeDelta *const delta)
 Add a TimeDelta to a Timestamp. More...
 
void Timestamp_add_DayDelta (struct Timestamp *const self, const struct DayDelta *const delta)
 Add a DayDelta to a Timestamp. More...
 
void Timestamp_add_MonthDelta (struct Timestamp *const self, const struct MonthDelta *const delta)
 Add a MonthDelta to a Timestamp. More...
 
void Timestamp_subtract_TimeDelta (struct Timestamp *const self, const struct TimeDelta *const delta)
 Subtract a TimeDelta from a Timestamp. More...
 
void Timestamp_subtract_DayDelta (struct Timestamp *const self, const struct DayDelta *const delta)
 Subtract a DayDelta from a Timestamp. More...
 
void Timestamp_subtract_MonthDelta (struct Timestamp *const self, const struct MonthDelta *const delta)
 Subtract a MonthDelta from a Timestamp. More...
 
short Timestamp_compare (const struct Timestamp *const lhs, const struct Timestamp *const rhs)
 Compare two Timestamp instances. More...
 
present_bool Timestamp_equal (const struct Timestamp *const lhs, const struct Timestamp *const rhs)
 Determine whether two Timestamp instances represent the exact same point in time (lhs == rhs). More...
 
present_bool Timestamp_less_than (const struct Timestamp *const lhs, const struct Timestamp *const rhs)
 Determine whether a Timestamp occurs earlier than another Timestamp (lhs < rhs). More...
 
present_bool Timestamp_less_than_or_equal (const struct Timestamp *const lhs, const struct Timestamp *const rhs)
 Determine whether a Timestamp occurs earlier than or at the same time as another Timestamp (lhs <= rhs). More...
 
present_bool Timestamp_greater_than (const struct Timestamp *const lhs, const struct Timestamp *const rhs)
 Determine whether a Timestamp occurs later than another Timestamp (lhs > rhs). More...
 
present_bool Timestamp_greater_than_or_equal (const struct Timestamp *const lhs, const struct Timestamp *const rhs)
 Determine whether a Timestamp occurs later than or at the same time as another Timestamp (lhs >= rhs). More...
 

Function Documentation

struct Timestamp Timestamp_from_time_t ( const time_t  time)

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

Parameters
timeThe "time_t" value representing the timestamp.
void Timestamp_ptr_from_time_t ( struct Timestamp *const  result,
const time_t  time 
)

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

Parameters
timeThe "time_t" value representing the timestamp.
[out]resultA pointer to a struct Timestamp for the result.
struct Timestamp Timestamp_from_struct_tm ( const struct tm  tm,
const struct TimeDelta *const  time_zone_offset 
)

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.
void Timestamp_ptr_from_struct_tm ( struct Timestamp *const  result,
const struct tm  tm,
const struct TimeDelta *const  time_zone_offset 
)

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.
[out]resultA pointer to a struct Timestamp for the result.
struct Timestamp Timestamp_from_struct_tm_utc ( const struct tm  tm)

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.
void Timestamp_ptr_from_struct_tm_utc ( struct Timestamp *const  result,
const struct tm  tm 
)

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.
[out]resultA pointer to a struct Timestamp for the result.
struct Timestamp Timestamp_from_struct_tm_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.

Parameters
tmThe "struct tm" value representing the date and time.
void Timestamp_ptr_from_struct_tm_local ( struct Timestamp *const  result,
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.

Parameters
tmThe "struct tm" value representing the date and time.
[out]resultA pointer to a struct Timestamp for the result.
struct Timestamp Timestamp_create ( const struct Date *const  date,
const struct ClockTime *const  clock_time,
const struct TimeDelta *const  time_zone_offset 
)

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.
void Timestamp_ptr_create ( struct Timestamp *const  result,
const struct Date *const  date,
const struct ClockTime *const  clock_time,
const struct TimeDelta *const  time_zone_offset 
)

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.
[out]resultA pointer to a struct Timestamp for the result.
struct Timestamp Timestamp_create_utc ( const struct Date *const  date,
const struct ClockTime *const  clock_time 
)

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.
void Timestamp_ptr_create_utc ( struct Timestamp *const  result,
const struct Date *const  date,
const struct ClockTime *const  clock_time 
)

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.
[out]resultA pointer to a struct Timestamp for the result.
struct Timestamp Timestamp_create_local ( const struct Date *const  date,
const struct ClockTime *const  clock_time 
)

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.
void Timestamp_ptr_create_local ( struct Timestamp *const  result,
const struct Date *const  date,
const struct ClockTime *const  clock_time 
)

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.
[out]resultA pointer to a struct Timestamp for the result.
struct Timestamp Timestamp_now ( void  )

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.

void Timestamp_ptr_now ( struct Timestamp *const  result)

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.

Parameters
[out]resultA pointer to a struct Timestamp for the result.
struct Timestamp Timestamp_epoch ( void  )

Create a new Timestamp representing the UNIX epoch (Jan.

1, 1970 00:00:00 UTC).

void Timestamp_ptr_epoch ( struct Timestamp *const  result)

Create a new Timestamp representing the UNIX epoch (Jan.

1, 1970 00:00:00 UTC).

Parameters
[out]resultA pointer to a struct Timestamp for the result.
time_t Timestamp_get_time_t ( const struct Timestamp *const  self)

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

struct tm Timestamp_get_struct_tm ( const struct Timestamp *const  self,
const struct TimeDelta *const  time_zone_offset 
)

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 struct Timestamp *const  self)

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

struct tm Timestamp_get_struct_tm_local ( const struct Timestamp *const  self)

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

struct Date Timestamp_get_date ( const struct Timestamp *const  self,
const struct TimeDelta *const  time_zone_offset 
)

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.

struct Date Timestamp_get_date_utc ( const struct Timestamp *const  self)

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

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

struct Date Timestamp_get_date_local ( const struct Timestamp *const  self)

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.

struct ClockTime Timestamp_get_clock_time ( const struct Timestamp *const  self,
const struct TimeDelta *const  time_zone_offset 
)

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.

struct ClockTime Timestamp_get_clock_time_utc ( const struct Timestamp *const  self)

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

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

struct ClockTime Timestamp_get_clock_time_local ( const struct Timestamp *const  self)

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.

struct TimeDelta Timestamp_difference ( const struct Timestamp *const  self,
const struct Timestamp *const  other 
)

Get the difference between two Timestamp instances as a TimeDelta.

struct TimeDelta Timestamp_absolute_difference ( const struct Timestamp *const  self,
const struct Timestamp *const  other 
)

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

void Timestamp_add_TimeDelta ( struct Timestamp *const  self,
const struct TimeDelta *const  delta 
)

Add a TimeDelta to a Timestamp.

void Timestamp_add_DayDelta ( struct Timestamp *const  self,
const struct DayDelta *const  delta 
)

Add a DayDelta to a Timestamp.

void Timestamp_add_MonthDelta ( struct Timestamp *const  self,
const struct MonthDelta *const  delta 
)

Add a MonthDelta to a Timestamp.

void Timestamp_subtract_TimeDelta ( struct Timestamp *const  self,
const struct TimeDelta *const  delta 
)

Subtract a TimeDelta from a Timestamp.

void Timestamp_subtract_DayDelta ( struct Timestamp *const  self,
const struct DayDelta *const  delta 
)

Subtract a DayDelta from a Timestamp.

void Timestamp_subtract_MonthDelta ( struct Timestamp *const  self,
const struct MonthDelta *const  delta 
)

Subtract a MonthDelta from a Timestamp.

short Timestamp_compare ( const struct Timestamp *const  lhs,
const struct Timestamp *const  rhs 
)

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.
present_bool Timestamp_equal ( const struct Timestamp *const  lhs,
const struct Timestamp *const  rhs 
)

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

present_bool Timestamp_less_than ( const struct Timestamp *const  lhs,
const struct Timestamp *const  rhs 
)

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

present_bool Timestamp_less_than_or_equal ( const struct Timestamp *const  lhs,
const struct Timestamp *const  rhs 
)

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

present_bool Timestamp_greater_than ( const struct Timestamp *const  lhs,
const struct Timestamp *const  rhs 
)

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

present_bool Timestamp_greater_than_or_equal ( const struct Timestamp *const  lhs,
const struct Timestamp *const  rhs 
)

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