Quick Links: |
#include <bdlt_timeutil.h>
Static Public Member Functions | |
static Time | convertFromHHMM (int timeValue) |
static Time | convertFromHHMMSS (int timeValue) |
static Time | convertFromHHMMSSmmm (int timeValue) |
static int | convertToHHMM (const Time &value) |
static int | convertToHHMMSS (const Time &value) |
static int | convertToHHMMSSmmm (const Time &value) |
static bool | isValidHHMM (int timeValue) |
static bool | isValidHHMMSS (int timeValue) |
static bool | isValidHHMMSSmmm (int timeValue) |
This struct
provides a namespace for common non-primitive procedures that operate on Time
objects. These methods are alias-safe and exception-neutral.
static Time bdlt::TimeUtil::convertFromHHMM | ( | int | timeValue | ) | [static] |
Return the bdlt::Time
value corresponding to the specified timeValue
, where timeValue
is a non-negative integer that, when expressed in decimal notation, contains exactly four digits (counting leading zeros, if any): two digits for the hour and two digits for the minute. For example, 309 is converted to Time(3, 9)
(03:09:00.000). More formally, timeValue
is interpreted as:
hour * 100 + minute
The behavior is undefined unless timeValue
represents a valid time in the allowable range for bdlt::Time
(00:00:00.000 - 23:59:00.000, and 24:00:00.000).
static Time bdlt::TimeUtil::convertFromHHMMSS | ( | int | timeValue | ) | [static] |
Return the bdlt::Time
value corresponding to the specified timeValue
, where timeValue
is a non-negative integer that, when expressed in decimal notation, contains exactly six digits (counting leading zeros, if any): two digits for the hour, two digits for the minute, and two digits for the second. For example, 30907 is converted to Time(3, 9, 7)
(03:09:07.000). More formally, timeValue
is interpreted as:
hour * 10000 + minute * 100 + second
The behavior is undefined unless timeValue
represents a valid time in the allowable range for bdlt::Time
(00:00:00.000 - 23:59:59.000, and 24:00:00.000).
static Time bdlt::TimeUtil::convertFromHHMMSSmmm | ( | int | timeValue | ) | [static] |
Return the bdlt::Time
value corresponding to the specified timeValue
, where timeValue
is a non-negative integer that, when expressed in decimal notation, contains exactly nine digits (counting leading zeros, if any): two digits for the hour, two digits for the minute, two digits for the second, and three digits for the millisecond. For example, 30907056 is converted to Time(3, 9, 7, 56)
(03:09:07.056). More formally, timeValue
is interpreted as:
hour * 10000000 + minute * 100000 + second * 1000 + millisecond
The behavior is undefined unless timeValue
represents a valid time in the allowable range for bdlt::Time
(00:00:00.000 - 23:59:59.999, and 24:00:00.000).
static int bdlt::TimeUtil::convertToHHMM | ( | const Time & | value | ) | [static] |
Return the non-negative integer representing the same time as the specified value
that, when expressed in decimal notation, contains exactly four digits (counting leading zeros, if any): two digits for the hour and two digits for the minute. For example, Time(3, 9, sec, ms)
, where 0 <= sec < 60
and 0 <= ms < 1000
, is converted to 309. More formally, this method returns:
value.hour() * 100 + value.minute()
static int bdlt::TimeUtil::convertToHHMMSS | ( | const Time & | value | ) | [static] |
Return the non-negative integer representing the same time as the specified value
that, when expressed in decimal notation, contains exactly six digits (counting leading zeros, if any): two digits for the hour, two digits for the minute, and two digits for the second. For example, Time(3, 9, 7, ms)
, where 0 <= ms < 1000
, is converted to 30907. More formally, this method returns:
value.hour() * 10000 + value.minute() * 100 + value.second()
static int bdlt::TimeUtil::convertToHHMMSSmmm | ( | const Time & | value | ) | [static] |
Return the non-negative integer representing the same time as the specified value
that, when expressed in decimal notation, contains exactly nine digits (counting leading zeros, if any): two digits for the hour, two digits for the minute, two digits for the second, and three digits for the millisecond. For example, Time(3, 9, 7, 56)
is converted to 30907056. More formally, this method returns:
value.hour() * 10000000 + value.minute() * 100000 + value.second() * 1000 + value.millisecond()
static bool bdlt::TimeUtil::isValidHHMM | ( | int | timeValue | ) | [static] |
Return true
if the specified timeValue
is a non-negative integer that represents a valid four-digit time value suitable for passing to convertFromHHMM
, and false
otherwise. timeValue
is a valid four-digit time value if, when expressed in decimal notation, it contains exactly four digits (counting leading zeros, if any): two digits for the hour and two digits for the minute, where either 0 <= hour < 24
and 0 <= minute < 60
, or 2400 == timeValue
.
static bool bdlt::TimeUtil::isValidHHMMSS | ( | int | timeValue | ) | [static] |
Return true
if the specified timeValue
is a non-negative integer that represents a valid six-digit time value suitable for passing to convertFromHHMMSS
, and false
otherwise. timeValue
is a valid six-digit time value if, when expressed in decimal notation, it contains exactly six digits (counting leading zeros, if any): two digits for the hour, two digits for the minute, and two digits for the second, where either 0 <= hour < 24
, 0 <= minute < 60
, and 0 <= second < 60
, or 240000 == timeValue
.
static bool bdlt::TimeUtil::isValidHHMMSSmmm | ( | int | timeValue | ) | [static] |
Return true
if the specified timeValue
is a non-negative integer that represents a valid nine-digit time value suitable for passing to convertFromHHMMSSmmm
, and false
otherwise. timeValue
is a valid nine-digit time value if, when expressed in decimal notation, it contains exactly nine digits (counting leading zeros, if any): two digits for the hour, two digits for the minute, two digits for the second, and three digits for the millisecond, where either 0 <= hour < 24
, 0 <= minute < 60
, 0 <= second < 60
, and 0 <= millisecond < 1000
, or 240000000 == timeValue
.