DCMTK
Version 3.6.1 20120515
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, const double timeZone=0) | |
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. | |
virtual OFBool | isValid () const |
check whether the currently stored time value is valid. | |
OFBool | setTime (const unsigned int hour, const unsigned int minute, const double second, const double timeZone=0) |
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 | setTimeInSeconds (const double seconds, const double timeZone=0, const OFBool normalize=OFTrue) |
set the time to the specified number of seconds | |
OFBool | setTimeInHours (const double hours, const double timeZone=0, const OFBool normalize=OFTrue) |
set the time to the specified number of hours | |
OFBool | setCurrentTime () |
set the time value to the current system time. | |
OFBool | setISOFormattedTime (const OFString &formattedTime) |
set the time value to the given ISO formatted time 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 OFString &timeZoneSeparator=" ") const |
get the current time value in ISO format. | |
Static Public Member Functions | |
static OFTime | getCurrentTime () |
get the current system time | |
static double | getLocalTimeZone () |
get the local 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 OFBool | isTimeValid (const unsigned int hour, const unsigned int minute, const double second, const double timeZone) |
check whether the given time is valid. | |
static double | getTimeInSeconds (const unsigned int hour, const unsigned int minute, const double second, const double timeZone=0, 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=0, const OFBool normalize=OFTrue) |
get the given time in hours. | |
Private Attributes | |
unsigned int | Hour |
currently stored hour value | |
unsigned int | Minute |
currently stored minute value | |
double | Second |
currently stored second value (incl. fraction of seconds) | |
double | TimeZone |
currently stored time zone value | |
Friends | |
class | OFDateTime |
This class provides a collection of time functions.
OFTime::OFTime | ( | ) |
default constructor.
Initializes Hour, Minute, Second and TimeZone to 0.
OFTime::OFTime | ( | const OFTime & | timeVal | ) |
copy constructor
timeVal | time object to be copied |
OFTime::OFTime | ( | const unsigned int | hour, |
const unsigned int | minute, | ||
const double | second, | ||
const double | timeZone = 0 |
||
) |
constructor with init values
hour | hour value to be set |
minute | minute value to be set |
second | second value to be set (incl. fraction of seconds) |
timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
virtual void OFTime::clear | ( | ) | [virtual] |
reset the time value.
Sets the hour, minute, second and time zone to "0".
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).
static OFTime OFTime::getCurrentTime | ( | ) | [static] |
get the current system time
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 OFString & | timeZoneSeparator = " " |
||
) | const |
get the current time value in ISO format.
The two ISO time formats supported by this function are
formattedTime | reference to string variable where the result is stored |
showSeconds | add optional seconds (":SS" or "SS") to the resulting string if OFTrue |
showFraction | add optional fractional part of a second (".FFFFFF") if OFTrue. Requires parameter 'seconds' to be also OFTrue. |
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 "&" is a placeholder for the sign symbol ("+" or "-"). |
showDelimiter | flag, indicating whether to use delimiters (":") or not |
timeZoneSeparator | separator between ISO time value and time zone. Only used if 'showDelimiter' is true. |
OFTime OFTime::getLocalTime | ( | ) | const |
get the currently stored time in local time.
The resulting time object always has the local time zone.
static double OFTime::getLocalTimeZone | ( | ) | [static] |
get the local time zone.
This function uses operating system dependent routines. If they are unavailable for some reason the Coordinated Universal Time is assumed (time zone offset = 0). 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 |
static double OFTime::getTimeInHours | ( | const unsigned int | hour, |
const unsigned int | minute, | ||
const double | second, | ||
const double | timeZone = 0 , |
||
const OFBool | normalize = OFTrue |
||
) | [static, protected] |
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 | 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 |
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 |
static double OFTime::getTimeInSeconds | ( | const unsigned int | hour, |
const unsigned int | minute, | ||
const double | second, | ||
const double | timeZone = 0 , |
||
const OFBool | normalize = OFTrue |
||
) | [static, protected] |
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 | 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 |
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 hour, i.e. 2 hours and 30 minutes).
static OFBool OFTime::isTimeValid | ( | const unsigned int | hour, |
const unsigned int | minute, | ||
const double | second, | ||
const double | timeZone | ||
) | [static, protected] |
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'
hour | hour value to be checked |
minute | minute value to be checked |
second | second value to be checked |
timeZone | offset to Coordinated Universal Time (UTC) in hours |
virtual OFBool OFTime::isValid | ( | ) | const [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' and [-12.0,+14.0] for 'timeZone'
virtual OFBool OFTime::operator!= | ( | const OFTime & | timeVal | ) | const [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 |
virtual OFBool OFTime::operator< | ( | const OFTime & | timeVal | ) | const [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 |
virtual OFBool OFTime::operator<= | ( | const OFTime & | timeVal | ) | const [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 |
assignment operator
timeVal | time value to be set |
virtual OFBool OFTime::operator== | ( | const OFTime & | timeVal | ) | const [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 |
virtual OFBool OFTime::operator> | ( | const OFTime & | timeVal | ) | const [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 |
virtual OFBool OFTime::operator>= | ( | const OFTime & | timeVal | ) | const [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 |
OFBool OFTime::setCurrentTime | ( | ) |
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.
OFBool OFTime::setCurrentTime | ( | const time_t & | tt | ) | [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 "isValid()" routine.
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 two ISO time formats supported by this function are
formattedTime | ISO formatted time value to be set |
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 "isValid()" routine.
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 "isValid()" routine.
second | new second value to be set (incl. fraction of seconds) |
OFBool OFTime::setTime | ( | const unsigned int | hour, |
const unsigned int | minute, | ||
const double | second, | ||
const double | timeZone = 0 |
||
) |
set the time value to the specified time.
Before the new value is set it is checked using the "isValid()" routine.
hour | new hour value to be set |
minute | new minute value to be set |
second | new second value to be set (incl. fraction of seconds) |
timeZone | optional offset to Coordinated Universal Time (UTC) in hours |
OFBool OFTime::setTimeInHours | ( | const double | hours, |
const double | timeZone = 0 , |
||
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 |
OFBool OFTime::setTimeInSeconds | ( | const double | seconds, |
const double | timeZone = 0 , |
||
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 |
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 the "isValid()" routine.
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 "isValid()" routine.
hour | new hour value to be set for the time zone |
minute | new minute value to be set for the time zone |