Present  0.9
 All Classes Files Functions Variables Typedefs Friends Macros Pages
clock-time.h File Reference

Go to the source code of this file.

Classes

struct  ClockTime
 Class or struct representing a time as seen on a clock. More...
 

Macros

#define ClockTime_create(...)
 Create a new ClockTime from either an hour (1 argument), an hour and a minute (2 arguments), an hour/minute/second (3 arguments), or an hour/minute/second/nanosecond (4 arguments). More...
 
#define ClockTime_ptr_create(result,...)
 Create a new ClockTime from either an hour (2 arguments), an hour and a minute (3 arguments), an hour/minute/second (4 arguments), or an hour/minute/second/nanosecond (5 arguments). More...
 

Functions

struct ClockTime ClockTime_from_hour (int_hour hour)
 Create a new ClockTime based on an hour of the day. More...
 
void ClockTime_ptr_from_hour (struct ClockTime *const result, int_hour hour)
 Create a new ClockTime based on an hour of the day. More...
 
struct ClockTime ClockTime_from_hour_minute (int_hour hour, int_minute minute)
 Create a new ClockTime based on an hour and a minute. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
struct ClockTime ClockTime_midnight (void)
 Create a new ClockTime initialized to midnight (00:00). More...
 
void ClockTime_ptr_midnight (struct ClockTime *const result)
 Create a new ClockTime initialized to midnight (00:00). More...
 
struct ClockTime ClockTime_noon (void)
 Create a new ClockTime initialized to noon (12:00). More...
 
void ClockTime_ptr_noon (struct ClockTime *const result)
 Create a new ClockTime initialized to noon (12:00). More...
 
int_hour ClockTime_hour (const struct ClockTime *const self)
 Get the hour component of a ClockTime (0 to 23, inclusive). More...
 
int_minute ClockTime_minute (const struct ClockTime *const self)
 Get the minute component of a ClockTime (0 to 59, inclusive). More...
 
int_second ClockTime_second (const struct ClockTime *const self)
 Get the second component of a ClockTime (0 to 59, inclusive). More...
 
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). More...
 
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 components. More...
 
struct TimeDelta ClockTime_time_since_midnight (const struct ClockTime *const self)
 Get a TimeDelta with the time since midnight of a ClockTime. More...
 
void ClockTime_add_TimeDelta (struct ClockTime *const self, const struct TimeDelta *const delta)
 Add a TimeDelta to a ClockTime. More...
 
void ClockTime_subtract_TimeDelta (struct ClockTime *const self, const struct TimeDelta *const delta)
 Subtract a TimeDelta from a ClockTime. More...
 
short ClockTime_compare (const struct ClockTime *const lhs, const struct ClockTime *const rhs)
 Compare two ClockTime instances. More...
 
present_bool ClockTime_equal (const struct ClockTime *const lhs, const struct ClockTime *const rhs)
 Determine whether two ClockTime instances are equal (lhs == rhs). More...
 
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). More...
 
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). More...
 
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). More...
 
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). More...
 

Macro Definition Documentation

#define ClockTime_create (   ...)
Value:
PRESENT_OVERLOAD_MAX_4(__VA_ARGS__, \
dummy)(__VA_ARGS__)
struct ClockTime ClockTime_from_hour(int_hour hour)
Create a new ClockTime based on an hour of the day.
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.
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.
struct ClockTime ClockTime_from_hour_minute(int_hour hour, int_minute minute)
Create a new ClockTime based on an hour and a minute.

Create a new ClockTime from either an hour (1 argument), an hour and a minute (2 arguments), an hour/minute/second (3 arguments), or an hour/minute/second/nanosecond (4 arguments).

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
ClockTime::has_error
ClockTime::errors
ClockTime_from_hour
ClockTime_from_hour_minute
ClockTime_from_hour_minute_second
ClockTime_from_hour_minute_second_nanosecond
#define ClockTime_ptr_create (   result,
  ... 
)
Value:
PRESENT_OVERLOAD_MAX_4(__VA_ARGS__, \
dummy)(result, __VA_ARGS__)
void ClockTime_ptr_from_hour(struct ClockTime *const result, int_hour hour)
Create a new ClockTime based on an hour of the day.
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.
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.
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.

Create a new ClockTime from either an hour (2 arguments), an hour and a minute (3 arguments), an hour/minute/second (4 arguments), or an hour/minute/second/nanosecond (5 arguments).

The first argument is a pointer to a struct ClockTime for the result.

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
ClockTime::has_error
ClockTime::errors
ClockTime_ptr_from_hour
ClockTime_ptr_from_hour_minute
ClockTime_ptr_from_hour_minute_second
ClockTime_ptr_from_hour_minute_second_nanosecond

Function Documentation

struct ClockTime ClockTime_from_hour ( int_hour  hour)

Create a new ClockTime based on an hour of the day.

If the hour is out of range, the ClockTime 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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
void ClockTime_ptr_from_hour ( struct ClockTime *const  result,
int_hour  hour 
)

Create a new ClockTime based on an hour of the day.

If the hour is out of range, the ClockTime 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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
[out]resultA pointer to a struct ClockTime for the result.
struct ClockTime ClockTime_from_hour_minute ( int_hour  hour,
int_minute  minute 
)

Create a new ClockTime based on an hour and a minute.

If the hour or the minute is out of range, the ClockTime 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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
minuteThe minute of the hour (0 to 59, inclusive).
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.

If the hour or the minute is out of range, the ClockTime 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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
minuteThe minute of the hour (0 to 59, inclusive).
[out]resultA pointer to a struct ClockTime for the result.
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.

If the hour, the minute, or the second is out of range, the ClockTime 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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
minuteThe minute of the hour (0 to 59, inclusive).
secondThe second of the minute (0 to 59, inclusive, or possibly 60 in the case of a leap second).
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.

If the hour, the minute, or the second is out of range, the ClockTime 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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
minuteThe minute of the hour (0 to 59, inclusive).
secondThe second of the minute (0 to 59, inclusive, or possibly 60 in the case of a leap second).
[out]resultA pointer to a struct ClockTime for the result.
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.

If the hour, minute, second, or nanosecond is out of range, the ClockTime 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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
minuteThe minute of the hour (0 to 59, inclusive).
secondThe second of the minute (0 to 59, inclusive, or possibly 60 in the case of a leap second).
nanosecondThe nanosecond (0 to 10^9-1, inclusive, i.e. no bigger than the number of nanoseconds in a second).
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.

If the hour, minute, second, or nanosecond is out of range, the ClockTime 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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
minuteThe minute of the hour (0 to 59, inclusive).
secondThe second of the minute (0 to 59, inclusive, or possibly 60 in the case of a leap second).
nanosecondThe nanosecond (0 to 10^9-1, inclusive, i.e. no bigger than the number of nanoseconds in a second).
[out]resultA pointer to a struct ClockTime for the result.
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.

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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
minuteThe minute of the hour (0 to 59, inclusive).
secondThe second of the minute (0 up to, but not including, 60).
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.

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
ClockTime::has_error
ClockTime::errors
Parameters
hourThe hour of the day (0 to 23, inclusive).
minuteThe minute of the hour (0 to 59, inclusive).
secondThe second of the minute (0 up to, but not including, 60).
[out]resultA pointer to a struct ClockTime for the result.
struct ClockTime ClockTime_midnight ( void  )

Create a new ClockTime initialized to midnight (00:00).

void ClockTime_ptr_midnight ( struct ClockTime *const  result)

Create a new ClockTime initialized to midnight (00:00).

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

Create a new ClockTime initialized to noon (12:00).

void ClockTime_ptr_noon ( struct ClockTime *const  result)

Create a new ClockTime initialized to noon (12:00).

Parameters
[out]resultA pointer to a struct ClockTime for the result.
int_hour ClockTime_hour ( const struct ClockTime *const  self)

Get the hour component of a ClockTime (0 to 23, inclusive).

int_minute ClockTime_minute ( const struct ClockTime *const  self)

Get the minute component of a ClockTime (0 to 59, inclusive).

int_second ClockTime_second ( const struct ClockTime *const  self)

Get the second component of a ClockTime (0 to 59, inclusive).

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).

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 components.

struct TimeDelta ClockTime_time_since_midnight ( const struct ClockTime *const  self)

Get a TimeDelta with the time since midnight of a ClockTime.

void ClockTime_add_TimeDelta ( struct ClockTime *const  self,
const struct TimeDelta *const  delta 
)

Add a TimeDelta to a ClockTime.

If the result goes above 23:59:59.999... or below 00:00, the ClockTime will wrap around.

void ClockTime_subtract_TimeDelta ( struct ClockTime *const  self,
const struct TimeDelta *const  delta 
)

Subtract a TimeDelta from a ClockTime.

If the result goes above 23:59:59.999... or below 00:00, the ClockTime will wrap around.

short ClockTime_compare ( const struct ClockTime *const  lhs,
const struct ClockTime *const  rhs 
)

Compare two ClockTime 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 ClockTime_equal ( const struct ClockTime *const  lhs,
const struct ClockTime *const  rhs 
)

Determine whether two ClockTime instances are equal (lhs == rhs).

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).

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).

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).

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).