17 #include "present/internal/cpp-guard.h"
18 #include "present/internal/header-utils.h"
21 #include "present/internal/present-clock-time-data.h"
23 #ifndef _PRESENT_CLOCK_TIME_H_
24 #define _PRESENT_CLOCK_TIME_H_
58 unsigned int hour_out_of_range : 1,
59 minute_out_of_range : 1,
60 second_out_of_range : 1,
61 nanosecond_out_of_range : 1;
65 struct PresentClockTimeData data_;
88 static ClockTime create_with_decimal_seconds(
112 double second_decimal()
const;
283 #define ClockTime_create(...) \
284 PRESENT_OVERLOAD_MAX_4(__VA_ARGS__, \
285 ClockTime_from_hour_minute_second_nanosecond, \
286 ClockTime_from_hour_minute_second, \
287 ClockTime_from_hour_minute, \
288 ClockTime_from_hour, \
304 #define ClockTime_ptr_create(result, ...) \
305 PRESENT_OVERLOAD_MAX_4(__VA_ARGS__, \
306 ClockTime_ptr_from_hour_minute_second_nanosecond, \
307 ClockTime_ptr_from_hour_minute_second, \
308 ClockTime_ptr_from_hour_minute, \
309 ClockTime_ptr_from_hour, \
310 dummy)(result, __VA_ARGS__)
present_int64 int_nanosecond
Definition: types.h:60
present_bool ClockTime_equal(const struct ClockTime *const lhs, const struct ClockTime *const rhs)
Determine whether two ClockTime instances are equal (lhs == rhs).
present_bool ClockTime_greater_than(const struct ClockTime *const lhs, const struct ClockTime *const rhs)
Determine whether a ClockTime is later than another ClockTime (lhs > rhs).
void ClockTime_ptr_midnight(struct ClockTime *const result)
Create a new ClockTime initialized to midnight (00:00).
int_hour ClockTime_hour(const struct ClockTime *const self)
Get the hour component of a ClockTime (0 to 23, inclusive).
int_hour hour() const
Get the hour component of a ClockTime (0 to 23, inclusive).
int_second ClockTime_second(const struct ClockTime *const self)
Get the second component of a ClockTime (0 to 59, inclusive).
void ClockTime_ptr_from_hour(struct ClockTime *const result, int_hour hour)
Create a new ClockTime based on an hour of the day.
Class or struct representing a time as seen on a clock.
Definition: clock-time.h:43
void ClockTime_ptr_from_hour_minute_second(struct ClockTime *const result, int_hour hour, int_minute minute, int_second second)
Create a new ClockTime based on an hour, a minute, and a second.
struct ClockTime ClockTime_from_hour(int_hour hour)
Create a new ClockTime based on an hour of the day.
present_int16 int_second
Definition: types.h:59
present_bool ClockTime_less_than(const struct ClockTime *const lhs, const struct ClockTime *const rhs)
Determine whether a ClockTime is earlier than another ClockTime (lhs < rhs).
int_minute ClockTime_minute(const struct ClockTime *const self)
Get the minute component of a ClockTime (0 to 59, inclusive).
void ClockTime_ptr_from_hour_minute_second_nanosecond(struct ClockTime *const result, int_hour hour, int_minute minute, int_second second, int_nanosecond nanosecond)
Create a new ClockTime based on an hour, a minute, a second, and a nanosecond.
struct TimeDelta ClockTime_time_since_midnight(const struct ClockTime *const self)
Get a TimeDelta with the time since midnight of a ClockTime.
present_int16 int_minute
Definition: types.h:58
present_bool ClockTime_greater_than_or_equal(const struct ClockTime *const lhs, const struct ClockTime *const rhs)
Determine whether a ClockTime is later than or the same as another ClockTime (lhs >= rhs)...
present_bool has_error
This will be true if there were any errors when creating this ClockTime.
Definition: clock-time.h:49
void ClockTime_ptr_from_hour_minute(struct ClockTime *const result, int_hour hour, int_minute minute)
Create a new ClockTime based on an hour and a minute.
void ClockTime_subtract_TimeDelta(struct ClockTime *const self, const struct TimeDelta *const delta)
Subtract a TimeDelta from a ClockTime.
struct ClockTime ClockTime_from_hour_minute_second_nanosecond(int_hour hour, int_minute minute, int_second second, int_nanosecond nanosecond)
Create a new ClockTime based on an hour, a minute, a second, and a nanosecond.
present_int16 int_hour
Definition: types.h:57
int_nanosecond nanosecond() const
Get the nanosecond component of a ClockTime (less than 10^9, the number of nanoseconds in a second)...
double ClockTime_second_decimal(const struct ClockTime *const self)
Get the second component of a ClockTime as a decimal, based on both the second and nanosecond compone...
void ClockTime_ptr_create_with_decimal_seconds(struct ClockTime *const result, int_hour hour, int_minute minute, double second)
Create a new ClockTime based on an hour, a minute, and a decimal second.
struct ClockTime ClockTime_noon(void)
Create a new ClockTime initialized to noon (12:00).
present_bool ClockTime_less_than_or_equal(const struct ClockTime *const lhs, const struct ClockTime *const rhs)
Determine whether a ClockTime is earlier than or or the same as another ClockTime (lhs <= rhs)...
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
int_minute minute() const
Get the minute component of a ClockTime (0 to 59, inclusive).
struct ClockTime ClockTime_create_with_decimal_seconds(int_hour hour, int_minute minute, double second)
Create a new ClockTime based on an hour, a minute, and a decimal second.
short ClockTime_compare(const struct ClockTime *const lhs, const struct ClockTime *const rhs)
Compare two ClockTime instances.
void ClockTime_add_TimeDelta(struct ClockTime *const self, const struct TimeDelta *const delta)
Add a TimeDelta to a ClockTime.
void ClockTime_ptr_noon(struct ClockTime *const result)
Create a new ClockTime initialized to noon (12:00).
int_second second() const
Get the second component of a ClockTime (0 to 59, inclusive).
struct ClockTime ClockTime_midnight(void)
Create a new ClockTime initialized to midnight (00:00).
struct ClockTime ClockTime_from_hour_minute_second(int_hour hour, int_minute minute, int_second second)
Create a new ClockTime based on an hour, a minute, and a second.
bool present_bool
Definition: types.h:21
struct ClockTime ClockTime_from_hour_minute(int_hour hour, int_minute minute)
Create a new ClockTime based on an hour and a minute.
int_nanosecond ClockTime_nanosecond(const struct ClockTime *const self)
Get the nanosecond component of a ClockTime (less than 10^9, the number of nanoseconds in a second)...