17 #include "present/internal/cpp-guard.h"
18 #include "present/internal/header-utils.h"
21 #include "present/internal/present-timestamp-data.h"
23 #ifndef _PRESENT_TIMESTAMP_H_
24 #define _PRESENT_TIMESTAMP_H_
59 unsigned int invalid_clock_time : 1,
64 struct PresentTimestampData data_;
68 static Timestamp create(
const time_t time);
75 static Timestamp create_utc(
const struct tm & tm);
77 static Timestamp create_local(
const struct tm & tm);
100 time_t get_time_t()
const;
103 struct tm get_struct_tm(const
TimeDelta & time_zone_offset)
const;
105 struct tm get_struct_tm_utc() const;
107 struct tm get_struct_tm_local() const;
112 Date get_date_utc()
const;
114 Date get_date_local()
const;
238 const struct
TimeDelta *
const time_zone_offset);
248 const struct TimeDelta *
const time_zone_offset);
306 const struct
Date *
const date,
307 const struct ClockTime *
const clock_time,
308 const struct TimeDelta *
const time_zone_offset);
317 const struct Date *
const date,
318 const struct ClockTime *
const clock_time,
319 const struct TimeDelta *
const time_zone_offset);
338 const struct
Date *
const date,
339 const struct ClockTime *
const clock_time);
348 const struct Date *
const date,
349 const struct ClockTime *
const clock_time);
368 const struct
Date *
const date,
369 const struct ClockTime *
const clock_time);
378 const struct Date *
const date,
379 const struct ClockTime *
const clock_time);
425 PRESENT_API
struct tm
428 const struct TimeDelta *
const time_zone_offset);
434 PRESENT_API
struct tm
441 PRESENT_API
struct tm
452 PRESENT_API
struct Date
455 const struct TimeDelta *
const time_zone_offset);
463 PRESENT_API
struct Date
473 PRESENT_API
struct Date
487 const struct TimeDelta *
const time_zone_offset);
542 const struct DayDelta *
const delta);
566 const struct DayDelta *
const delta);
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...
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)...
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 Universa...
void Timestamp_ptr_now(struct Timestamp *const result)
Create a new Timestamp representing the exact time right now.
void Timestamp_add_MonthDelta(struct Timestamp *const self, const struct MonthDelta *const delta)
Add a MonthDelta to a Timestamp.
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 zon...
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).
Class or struct representing a time as seen on a clock.
Definition: clock-time.h:43
struct ClockTime Timestamp_get_clock_time_utc(const struct Timestamp *const self)
Get the ClockTime component of a Timestamp in Coordinated Universal Time.
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...
time_t Timestamp_get_time_t(const struct Timestamp *const self)
Convert a Timestamp to a "time_t" (from C's time library).
struct Timestamp Timestamp_epoch(void)
Create a new Timestamp representing the UNIX epoch (Jan.
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)...
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).
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...
struct Timestamp Timestamp_now(void)
Create a new Timestamp representing the exact time right now.
struct TimeDelta Timestamp_difference(const struct Timestamp *const self, const struct Timestamp *const other)
Get the difference between two Timestamp instances as a TimeDelta.
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)...
void Timestamp_subtract_MonthDelta(struct Timestamp *const self, const struct MonthDelta *const delta)
Subtract a MonthDelta from a Timestamp.
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.
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.
void Timestamp_ptr_epoch(struct Timestamp *const result)
Create a new Timestamp representing the UNIX epoch (Jan.
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...
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...
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 Universa...
void Timestamp_subtract_DayDelta(struct Timestamp *const self, const struct DayDelta *const delta)
Subtract a DayDelta from a 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)...
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.
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.
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.
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...
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).
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.
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.
present_bool has_error
This will be true if there were any errors when creating this Timestamp.
Definition: timestamp.h:50
Class or struct representing a positive or negative delta of a number of days or weeks.
Definition: day-delta.h:40
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).
Class or struct representing a calendar date.
Definition: date.h:59
Class or struct representing a positive or negative delta of a number of nanoseconds, seconds, minutes, hours, days, or weeks.
Definition: time-delta.h:40
Class or struct representing an exact point in time.
Definition: timestamp.h:44
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...
void Timestamp_add_DayDelta(struct Timestamp *const self, const struct DayDelta *const delta)
Add a DayDelta to a Timestamp.
short Timestamp_compare(const struct Timestamp *const lhs, const struct Timestamp *const rhs)
Compare two Timestamp instances.
void Timestamp_subtract_TimeDelta(struct Timestamp *const self, const struct TimeDelta *const delta)
Subtract a TimeDelta from a Timestamp.
void Timestamp_add_TimeDelta(struct Timestamp *const self, const struct TimeDelta *const delta)
Add a TimeDelta to a Timestamp.
struct Date Timestamp_get_date_utc(const struct Timestamp *const self)
Get the Date component of a Timestamp in Coordinated Universal Time.
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 <= rh...
bool present_bool
Definition: types.h:21
Class or struct representing a positive or negative delta of a number of months or years...
Definition: month-delta.h:38
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...