|
DCMTK Version 3.7.1
OFFIS DICOM Toolkit
|
This class provides a collection of time functions. More...
Public Member Functions | |
| OFTime () | |
| default constructor. | |
| OFTime (const OFTime &timeVal) | |
| copy constructor | |
| OFTime (const unsigned int hour, const unsigned int minute, const double second=unspecifiedSecond, const double timeZone=unspecifiedTimeZone) | |
| constructor with init values | |
| virtual | ~OFTime () |
| destructor | |
| virtual OFTime & | operator= (const OFTime &timeVal) |
| assignment operator | |
| virtual OFBool | operator== (const OFTime &timeVal) const |
| comparison operator (equal). | |
| virtual OFBool | operator!= (const OFTime &timeVal) const |
| comparison operator (unequal) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared. | |
| virtual OFBool | operator< (const OFTime &timeVal) const |
| comparison operator (less than) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared. | |
| virtual OFBool | operator<= (const OFTime &timeVal) const |
| comparison operator (less than or equal) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared. | |
| virtual OFBool | operator>= (const OFTime &timeVal) const |
| comparison operator (greater than or equal) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared. | |
| virtual OFBool | operator> (const OFTime &timeVal) const |
| comparison operator (greater than) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared. | |
| virtual void | clear () |
| reset the time value. | |
| void | clearSecond () |
| clear the second value, i.e. set it to "unspecified" | |
| void | clearTimeZone () |
| clear the time zone value, i.e. set it to "unspecified" | |
| virtual OFBool | isValid () const |
| check whether the currently stored time value is valid. | |
| virtual OFBool | hasSecond () const |
| check whether a second value is specified | |
| virtual OFBool | hasFractionOfSecond () const |
| check whether the second value has a fractional part, i.e. it is not an integer | |
| virtual OFBool | hasTimeZone () const |
| check whether a time zone value is specified, i.e. an offset to Coordinated Universal Time (UTC) | |
| OFBool | setTime (const unsigned int hour, const unsigned int minute, const double second=unspecifiedSecond, const double timeZone=unspecifiedTimeZone) |
| set the time value to the specified time. | |
| OFBool | setHour (const unsigned int hour) |
| set the time value to the specified hour. | |
| OFBool | setMinute (const unsigned int minute) |
| set the time value to the specified minute. | |
| OFBool | setSecond (const double second) |
| set the time value to the specified second. | |
| OFBool | setTimeZone (const double timeZone) |
| set the time zone to the specified value. | |
| OFBool | setTimeZone (const signed int hour, const unsigned int minute) |
| set the time zone to the specified value. | |
| OFBool | setLocalTimeZone () |
| set the time zone to the local time zone. | |
| OFBool | setTimeInSeconds (const double seconds, const double timeZone=unspecifiedTimeZone, const OFBool normalize=OFTrue) |
| set the time to the specified number of seconds | |
| OFBool | setTimeInHours (const double hours, const double timeZone=unspecifiedTimeZone, const OFBool normalize=OFTrue) |
| set the time to the specified number of hours | |
| OFBool | setCurrentTime () |
| set the time value to the current system time, including the local time zone. | |
| OFBool | setISOFormattedTime (const OFString &formattedTime) |
| set the time value to the given ISO formatted time string. | |
| OFBool | setISOFormattedTimeZone (const OFString &formattedTimeZone) |
| set the time zone value to the given ISO formatted time zone string. | |
| unsigned int | getHour () const |
| get the currently stored hour value | |
| unsigned int | getMinute () const |
| get the currently stored minute value | |
| double | getSecond () const |
| get the currently stored second value | |
| unsigned int | getIntSecond () const |
| get the integral part of the currently stored second value | |
| unsigned int | getMilliSecond () const |
| get the milli second part of the currently stored second value | |
| unsigned int | getMicroSecond () const |
| get the micro second part of the currently stored second value | |
| double | getTimeZone () const |
| get the currently stored time zone value. | |
| double | getTimeInSeconds (const OFBool useTimeZone=OFFalse, const OFBool normalize=OFTrue) const |
| get the currently stored time in seconds | |
| double | getTimeInHours (const OFBool useTimeZone=OFFalse, const OFBool normalize=OFTrue) const |
| get the currently stored time in hours. | |
| OFTime | getCoordinatedUniversalTime () const |
| get the currently stored time as Coordinated Universal Time. | |
| OFTime | getLocalTime () const |
| get the currently stored time in local time. | |
| OFBool | getISOFormattedTime (OFString &formattedTime, const OFBool showSeconds=OFTrue, const OFBool showFraction=OFFalse, const OFBool showTimeZone=OFFalse, const OFBool showDelimiter=OFTrue, const OFBool createMissingPart=OFFalse, const OFString &timeZoneSeparator=" ") const |
| get the current time value in ISO format. | |
| OFBool | getISOFormattedTimeZone (OFString &formattedTimeZone, const OFBool showDelimiter=OFTrue) const |
| get the current time zone value in ISO format. | |
Static Public Member Functions | |
| static OFTime | getCurrentTime () |
| get the current system time | |
| static double | getLocalTimeZone () |
| get the local time zone. | |
| static OFBool | isTimeValid (const unsigned int hour, const unsigned int minute, const double second=unspecifiedSecond, const double timeZone=unspecifiedTimeZone) |
| check whether the given time is valid. | |
| static OFBool | isSecondSpecified (const double second) |
| check whether the given second value is specified | |
| static OFBool | isTimeZoneValid (const double timeZone, const OFBool acceptUnspecified=OFFalse) |
| check whether the given time zone is valid, i.e. within the valid range, or unspecified if explicitly accepted. | |
| static OFBool | isTimeZoneSpecified (const double timeZone) |
| check whether the given time zone is specified | |
Static Public Attributes | |
| static const double | unspecifiedSecond |
| constant value that denotes an unspecified second. | |
| static const double | unspecifiedTimeZone |
| constant value that denotes an unspecified time zone. | |
Protected Member Functions | |
| OFBool | setCurrentTime (const time_t &tt) |
| set the time value to the current system time. | |
Static Protected Member Functions | |
| static double | getTimeInSeconds (const unsigned int hour, const unsigned int minute, const double second, const double timeZone=unspecifiedTimeZone, const OFBool normalize=OFTrue) |
| get the given time in seconds | |
| static double | getTimeInHours (const unsigned int hour, const unsigned int minute, const double second, const double timeZone=unspecifiedTimeZone, const OFBool normalize=OFTrue) |
| get the given time in hours | |
Friends | |
| class | OFDateTime |
This class provides a collection of time functions.
| OFTime::OFTime | ( | ) |
default constructor.
Initializes hour, minute and second to 0, and time zone to "unspecified".
Referenced by OFTime(), getCoordinatedUniversalTime(), getCurrentTime(), getLocalTime(), operator!=(), operator<(), operator<=(), operator=(), operator==(), operator>(), and operator>=().
| OFTime::OFTime | ( | const OFTime & | timeVal | ) |
| OFTime::OFTime | ( | const unsigned int | hour, |
| const unsigned int | minute, | ||
| const double | second = unspecifiedSecond, | ||
| const double | timeZone = unspecifiedTimeZone ) |
constructor with init values
| hour | hour value to be set |
| minute | minute value to be set |
| second | optional second value to be set (including fraction of seconds) |
| timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
References unspecifiedSecond, and unspecifiedTimeZone.
|
virtual |
reset the time value.
Sets the hour and minute to 0, and second as well as time zone to "unspecified".
| OFTime OFTime::getCoordinatedUniversalTime | ( | ) | const |
get the currently stored time as Coordinated Universal Time.
The resulting time object always has a time zone of "+00:00" since the time is corrected regarding the Coordinated Universal Time (UTC).
References OFTime().
|
static |
get the current system time
References OFTime().
| unsigned int OFTime::getHour | ( | ) | const |
get the currently stored hour value
| unsigned int OFTime::getIntSecond | ( | ) | const |
get the integral part of the currently stored second value
| OFBool OFTime::getISOFormattedTime | ( | OFString & | formattedTime, |
| const OFBool | showSeconds = OFTrue, | ||
| const OFBool | showFraction = OFFalse, | ||
| const OFBool | showTimeZone = OFFalse, | ||
| const OFBool | showDelimiter = OFTrue, | ||
| const OFBool | createMissingPart = OFFalse, | ||
| const OFString & | timeZoneSeparator = " " ) const |
get the current time value in ISO format.
The ISO time formats supported by this function are
where the brackets enclose optional parts and the "&" is a placeholder for the sign symbol ("+" or "-").
| formattedTime | reference to string variable where the result is stored |
| showSeconds | add optional seconds (":SS" or "SS") to the resulting string if OFTrue. By default, the seconds are only added if a value is specified. |
| showFraction | add optional fractional part of a second (".FFFFFF") if OFTrue. Requires parameter 'seconds' to be also OFTrue. By default, the fractional part is only added if the second value is not an integer (see hasFractionOfSecond()). |
| showTimeZone | add optional time zone ("&ZZ:ZZ" or "&ZZZZ") to the resulting string if OFTrue. The time zone indicates the offset from the Coordinated Universal Time (UTC) in hours and minutes. The time zone is only added if a value is specified. |
| showDelimiter | flag, indicating whether to use delimiters (":" and " ") or not |
| createMissingPart | if OFTrue, create optional parts (seconds and fractional part of a second) even if not specified (see hasSecond() and hasFractionOfSecond()) |
| timeZoneSeparator | separator between ISO time value and time zone, e.g. " " (default) or "" (for ISO 8601 format). Only used if 'showDelimiter' is true. |
Referenced by DcmIODUtil::setContentDateAndTimeNow().
| OFBool OFTime::getISOFormattedTimeZone | ( | OFString & | formattedTimeZone, |
| const OFBool | showDelimiter = OFTrue ) const |
get the current time zone value in ISO format.
The two ISO time zone formats supported by this function are
where the "&" is a placeholder for the sign symbol ("+" or "-").
| formattedTimeZone | reference to string variable where the result is stored |
| showDelimiter | flag, indicating whether to use a delimiter (":") or not |
| OFTime OFTime::getLocalTime | ( | ) | const |
get the currently stored time in local time.
The resulting time object always has the local time zone.
References OFTime().
|
static |
get the local time zone.
This function uses operating system dependent routines. If they are unavailable for some reason, the time zone is set to "unspecified". Also please note that time zones in the range ]+12.0,+14.0] cannot be detected due to the internally used algorithm.
| unsigned int OFTime::getMicroSecond | ( | ) | const |
get the micro second part of the currently stored second value
| unsigned int OFTime::getMilliSecond | ( | ) | const |
get the milli second part of the currently stored second value
| unsigned int OFTime::getMinute | ( | ) | const |
get the currently stored minute value
| double OFTime::getSecond | ( | ) | const |
get the currently stored second value
| double OFTime::getTimeInHours | ( | const OFBool | useTimeZone = OFFalse, |
| const OFBool | normalize = OFTrue ) const |
get the currently stored time in hours.
| useTimeZone | use the currently set time zone to correct the result |
| normalize | if OFTrue, results larger than or equal 24.0 (hours) are normalized to a valid range |
|
staticprotected |
get the given time in hours
| hour | hour value of the given time |
| minute | minute value of the given time |
| second | second value of the given time |
| timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
| normalize | if OFTrue, results larger than or equal 24.0 (hours) are normalized to a valid range |
References unspecifiedTimeZone.
| double OFTime::getTimeInSeconds | ( | const OFBool | useTimeZone = OFFalse, |
| const OFBool | normalize = OFTrue ) const |
get the currently stored time in seconds
| useTimeZone | use the currently set time zone to correct the result |
| normalize | if OFTrue, results larger than or equal 86400.0 (seconds) are normalized to a valid range |
|
staticprotected |
get the given time in seconds
| hour | hour value of the given time |
| minute | minute value of the given time |
| second | second value of the given time |
| timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
| normalize | if OFTrue, results larger than or equal 86400.0 (seconds) are normalized to a valid range |
References unspecifiedTimeZone.
| double OFTime::getTimeZone | ( | ) | const |
get the currently stored time zone value.
The time zone is given as the offset (in hours) to the Coordinated Universal Time (UTC). Valid values are for instance "+1.0" (plus one hour) and "-2.5" (minus two and a half hours, i.e. 2 hours and 30 minutes). Use hasTimeZone() to make sure that a time zone value is actually specified. Alternatively, the static functions isTimeZoneValid() and isTimeZoneSpecified() can be used to check whether the returned value is valid and/or specified.
|
virtual |
check whether the second value has a fractional part, i.e. it is not an integer
|
virtual |
check whether a second value is specified
|
virtual |
check whether a time zone value is specified, i.e. an offset to Coordinated Universal Time (UTC)
|
static |
check whether the given second value is specified
| second | second value to be checked |
|
static |
check whether the given time is valid.
Valid ranges: [0,24[ for 'hour', [0,60[ for 'minute', [0.0,60.0[ for 'second' and [-12.0,+14.0] for 'timeZone' (if specified)
| hour | hour value to be checked |
| minute | minute value to be checked |
| second | optional second value to be checked |
| timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
References unspecifiedSecond, and unspecifiedTimeZone.
|
static |
check whether the given time zone is specified
| timeZone | offset to Coordinated Universal Time (UTC) in hours |
|
static |
check whether the given time zone is valid, i.e. within the valid range, or unspecified if explicitly accepted.
Valid range: [-12.0,+14.0]
| timeZone | offset to Coordinated Universal Time (UTC) in hours |
| acceptUnspecified | also accept unspecified time zone if OFTrue |
|
virtual |
check whether the currently stored time value is valid.
Valid ranges: [0,24[ for 'hour', [0,60[ for 'minute', [0.0,60.0] for 'second' (including leap second) and [-12.0,+14.0] for 'timeZone'
|
virtual |
comparison operator (unequal) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared.
| timeVal | time value compared with the current value |
References OFTime().
|
virtual |
comparison operator (less than) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared.
| timeVal | time value compared with the current value |
References OFTime().
|
virtual |
comparison operator (less than or equal) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared.
| timeVal | time value compared with the current value |
References OFTime().
assignment operator
| timeVal | time value to be set |
References OFTime().
|
virtual |
comparison operator (equal).
Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared.
| timeVal | time value compared with the current value |
References OFTime().
|
virtual |
comparison operator (greater than) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared.
| timeVal | time value compared with the current value |
References OFTime().
|
virtual |
comparison operator (greater than or equal) Please note that the time values are first transformed to the Coordinated Universal Time (UTC) before they are compared.
| timeVal | time value compared with the current value |
References OFTime().
| OFBool OFTime::setCurrentTime | ( | ) |
set the time value to the current system time, including the local time zone.
This function uses operating system dependent routines. If they are unavailable for some reason the current value is not modified.
Referenced by DcmIODUtil::setContentDateAndTimeNow().
|
protected |
set the time value to the current system time.
This function uses operating system dependent routines. If they are unavailable for some reason the current value is not modified.
| tt | current system time (as returned by the time() function) |
| OFBool OFTime::setHour | ( | const unsigned int | hour | ) |
set the time value to the specified hour.
Before the new value is set, it is checked using the isTimeValid() method.
| hour | new hour value to be set |
| OFBool OFTime::setISOFormattedTime | ( | const OFString & | formattedTime | ) |
set the time value to the given ISO formatted time string.
The most common ISO time formats supported by this function are
where the brackets enclose optional parts and the "&" is a placeholder for the sign symbol ("+" or "-"). The pattern "FFFFFF" contains a fractional part of a second. If specified, it shall contain one to six digits representing a range from 0 to 999999. In the first two formats listed, spaces between time and time zone components are accepted. Leading or trailing spaces are never accepted.
| formattedTime | ISO formatted time value to be set |
| OFBool OFTime::setISOFormattedTimeZone | ( | const OFString & | formattedTimeZone | ) |
set the time zone value to the given ISO formatted time zone string.
The two ISO time zone formats supported by this function are
where the "&" is a placeholder for the sign symbol ("+" or "-").
| formattedTimeZone | ISO formatted time zone value to be set, or an empty string |
| OFBool OFTime::setLocalTimeZone | ( | ) |
set the time zone to the local time zone.
See getLocalTimeZone() for details.
| OFBool OFTime::setMinute | ( | const unsigned int | minute | ) |
set the time value to the specified minute.
Before the new value is set, it is checked using the isTimeValid() method.
| minute | new minute value to be set |
| OFBool OFTime::setSecond | ( | const double | second | ) |
set the time value to the specified second.
Before the new value is set, it is checked using the isTimeValid() method.
| second | new second value to be set (including fraction of seconds) |
| OFBool OFTime::setTime | ( | const unsigned int | hour, |
| const unsigned int | minute, | ||
| const double | second = unspecifiedSecond, | ||
| const double | timeZone = unspecifiedTimeZone ) |
set the time value to the specified time.
Before the new value is set, it is checked using the isTimeValid() method.
| hour | new hour value to be set |
| minute | new minute value to be set |
| second | optional second value to be set (including fraction of seconds) |
| timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
References unspecifiedSecond, and unspecifiedTimeZone.
| OFBool OFTime::setTimeInHours | ( | const double | hours, |
| const double | timeZone = unspecifiedTimeZone, | ||
| const OFBool | normalize = OFTrue ) |
set the time to the specified number of hours
| hours | number of hours since "00:00:00" specifying time to set |
| timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
| normalize | if OFTrue, the 'hours' value is normalized to the valid range [0.0,24.0[ otherwise the value is checked as is |
References unspecifiedTimeZone.
| OFBool OFTime::setTimeInSeconds | ( | const double | seconds, |
| const double | timeZone = unspecifiedTimeZone, | ||
| const OFBool | normalize = OFTrue ) |
set the time to the specified number of seconds
| seconds | number of seconds since "00:00:00" specifying time to set |
| timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
| normalize | if OFTrue, the 'seconds' value is normalized to the valid range [0.0,86400.0[ otherwise the value is checked as is |
References unspecifiedTimeZone.
| OFBool OFTime::setTimeZone | ( | const double | timeZone | ) |
set the time zone to the specified value.
The time zone is given as the offset (in hours) to the Coordinated Universal Time (UTC). Valid values are for instance "+1.0" (plus one hour) and "-2.5" (minus two and a half hour, i.e. 2 hours and 30 minutes). Before the new value is set, it is checked using isTimeZoneSpecified() and isTimeZoneValid().
| timeZone | new timeZone value to be set |
| OFBool OFTime::setTimeZone | ( | const signed int | hour, |
| const unsigned int | minute ) |
set the time zone to the specified value.
The time zone is given as the offset (in hours and minutes) to the Coordinated Universal Time (UTC). Before the new value is set, it is checked using the isTimeZoneValid() method.
| hour | new hour value to be set for the time zone |
| minute | new minute value to be set for the time zone |
|
static |
constant value that denotes an unspecified second.
Referenced by OFTime(), isTimeValid(), and setTime().
|
static |
constant value that denotes an unspecified time zone.
Referenced by OFDateTime::OFDateTime(), OFTime(), DcmTime::getOFTimeFromString(), DcmTime::getOFTimeFromString(), getTimeInHours(), getTimeInSeconds(), isTimeValid(), OFDateTime::setDateTime(), setTime(), setTimeInHours(), and setTimeInSeconds().