Class or struct representing a time as seen on a clock. More...
Public Member Functions | |
| int_hour | hour () const |
| Get the hour component of a ClockTime (0 to 23, inclusive). More... | |
| int_minute | minute () const |
| Get the minute component of a ClockTime (0 to 59, inclusive). More... | |
| int_second | second () const |
| Get the second component of a ClockTime (0 to 59, inclusive). More... | |
| int_nanosecond | nanosecond () const |
| Get the nanosecond component of a ClockTime (less than 10^9, the number of nanoseconds in a second). More... | |
| double | second_decimal () const |
| Get the second component of a ClockTime as a decimal, based on both the second and nanosecond components. More... | |
| TimeDelta | time_since_midnight () const |
| Get a TimeDelta with the time since midnight of a ClockTime. More... | |
| ClockTime & | operator+= (const TimeDelta &delta) |
| Add a TimeDelta to a ClockTime. More... | |
| ClockTime & | operator-= (const TimeDelta &delta) |
| Subtract a TimeDelta from a ClockTime. More... | |
Static Public Member Functions | |
| static ClockTime | create (int_hour hour) |
| Create a new ClockTime based on an hour of the day. More... | |
| static ClockTime | create (int_hour hour, int_minute minute) |
| Create a new ClockTime based on an hour and a minute. More... | |
| static ClockTime | create (int_hour hour, int_minute minute, int_second second) |
| Create a new ClockTime based on an hour, a minute, and a second. More... | |
| static ClockTime | create (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... | |
| static 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... | |
| static ClockTime | midnight (void) |
| Create a new ClockTime initialized to midnight (00:00). More... | |
| static ClockTime | noon () |
| Create a new ClockTime initialized to noon (12:00). More... | |
| static short | compare (const ClockTime &lhs, const ClockTime &rhs) |
| Compare two ClockTime instances. More... | |
Public Attributes | |
| present_bool | has_error |
| This will be true if there were any errors when creating this ClockTime. More... | |
| struct { | |
| unsigned int hour_out_of_range: 1 | |
| unsigned int minute_out_of_range: 1 | |
| unsigned int second_out_of_range: 1 | |
| unsigned int nanosecond_out_of_range: 1 | |
| } | errors |
| If there were any errors when creating this ClockTime, then one or more of these fields will be set. More... | |
| struct PresentClockTimeData | data_ |
Friends | |
| const ClockTime | operator+ (const ClockTime &lhs, const TimeDelta &rhs) |
| const ClockTime | operator+ (const TimeDelta &lhs, const ClockTime &rhs) |
| const ClockTime | operator- (const ClockTime &lhs, const TimeDelta &rhs) |
| bool | operator== (const ClockTime &lhs, const ClockTime &rhs) |
| Determine whether two ClockTime instances are equal (lhs == rhs). More... | |
| bool | operator!= (const ClockTime &lhs, const ClockTime &rhs) |
| bool | operator< (const ClockTime &lhs, const ClockTime &rhs) |
| Determine whether a ClockTime is earlier than another ClockTime (lhs < rhs). More... | |
| bool | operator<= (const ClockTime &lhs, const ClockTime &rhs) |
| Determine whether a ClockTime is earlier than or or the same as another ClockTime (lhs <= rhs). More... | |
| bool | operator> (const ClockTime &lhs, const ClockTime &rhs) |
| Determine whether a ClockTime is later than another ClockTime (lhs > rhs). More... | |
| bool | operator>= (const ClockTime &lhs, const ClockTime &rhs) |
| Determine whether a ClockTime is later than or the same as another ClockTime (lhs >= rhs). More... | |
Class or struct representing a time as seen on a clock.
This includes hours, minutes, and seconds (up to nanosecond precision). There is no date information stored with the time, nor a time zone (so a ClockTime instance is NOT tied to a specific time zone).
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.
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.
| hour | The hour of the day (0 to 23, inclusive). |
|
static |
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.
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.
| hour | The hour of the day (0 to 23, inclusive). |
| minute | The minute of the hour (0 to 59, inclusive). |
|
static |
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.
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.
| hour | The hour of the day (0 to 23, inclusive). |
| minute | The minute of the hour (0 to 59, inclusive). |
| second | The second of the minute (0 to 59, inclusive, or possibly 60 in the case of a leap second). |
|
static |
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.
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.
| hour | The hour of the day (0 to 23, inclusive). |
| minute | The minute of the hour (0 to 59, inclusive). |
| second | The second of the minute (0 to 59, inclusive, or possibly 60 in the case of a leap second). |
| nanosecond | The nanosecond (0 to 10^9-1, inclusive, i.e. no bigger than the number of nanoseconds in a second). |
|
static |
Create a new ClockTime based on an hour, a minute, and a decimal second.
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.
| hour | The hour of the day (0 to 23, inclusive). |
| minute | The minute of the hour (0 to 59, inclusive). |
| second | The second of the minute (0 up to, but not including, 60). |
|
static |
Create a new ClockTime initialized to midnight (00:00).
| int_minute ClockTime::minute | ( | ) | const |
Get the minute component of a ClockTime (0 to 59, inclusive).
| int_second ClockTime::second | ( | ) | const |
Get the second component of a ClockTime (0 to 59, inclusive).
| int_nanosecond ClockTime::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 |
Get the second component of a ClockTime as a decimal, based on both the second and nanosecond components.
| TimeDelta ClockTime::time_since_midnight | ( | ) | const |
Compare two ClockTime instances.
Determine whether two ClockTime instances are equal (lhs == rhs).
| present_bool ClockTime::has_error |
This will be true if there were any errors when creating this ClockTime.
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 ClockTime::hour_out_of_range |
| unsigned int ClockTime::minute_out_of_range |
| unsigned int ClockTime::second_out_of_range |
| unsigned int ClockTime::nanosecond_out_of_range |
| struct { ... } ClockTime::errors |
If there were any errors when creating this ClockTime, 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 PresentClockTimeData ClockTime::data_ |