OFTime Class Reference

This class provides a collection of time functions. More...

List of all members.

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 OFTimeoperator= (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
 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


Detailed Description

This class provides a collection of time functions.

Definition at line 53 of file oftime.h.


Constructor & Destructor Documentation

OFTime::OFTime (  ) 

default constructor.

Initializes Hour, Minute, Second and TimeZone to 0.

OFTime::OFTime ( const OFTime timeVal  ) 

copy constructor

Parameters:
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

Parameters:
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


Member Function Documentation

virtual OFTime& OFTime::operator= ( const OFTime timeVal  )  [virtual]

assignment operator

Parameters:
timeVal time value to be set
Returns:
reference to this object (with new value)

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.

Parameters:
timeVal time value compared with the current value
Returns:
OFTrue if given time is equal, OFFalse otherwise

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.

Parameters:
timeVal time value compared with the current value
Returns:
OFTrue if given time is unequal, OFFalse otherwise

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.

Parameters:
timeVal time value compared with the current value
Returns:
OFTrue if current time is earlier than the given value, OFFalse otherwise

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.

Parameters:
timeVal time value compared with the current value
Returns:
OFTrue if current time is earlier than or identical to the given value, OFFalse otherwise

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.

Parameters:
timeVal time value compared with the current value
Returns:
OFTrue if current time is later than or identical to the given value, OFFalse otherwise

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.

Parameters:
timeVal time value compared with the current value
Returns:
OFTrue if current time is later than the given value, OFFalse otherwise

virtual void OFTime::clear (  )  [virtual]

reset the time value.

Sets the hour, minute, second and time zone to "0".

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,+12.0] for 'timeZone'

Returns:
OFTrue if the current value is valid, OFFalse otherwise

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.

Parameters:
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
Returns:
OFTrue if the new value is valid and has been set, OFFalse otherwise

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.

Parameters:
hour new hour value to be set
Returns:
OFTrue if the new value is valid and has been set, OFFalse otherwise

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.

Parameters:
minute new minute value to be set
Returns:
OFTrue if the new value is valid and has been set, OFFalse otherwise

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.

Parameters:
second new second value to be set (incl. fraction of seconds)
Returns:
OFTrue if the new value is valid and has been set, OFFalse otherwise

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.

Parameters:
timeZone new timeZone value to be set
Returns:
OFTrue if the new value is valid and has been set, OFFalse otherwise

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.

Parameters:
hour new hour value to be set for the time zone
minute new minute value to be set for the time zone
Returns:
OFTrue if the new value is valid and has been set, OFFalse otherwise

OFBool OFTime::setTimeInSeconds ( const double  seconds,
const double  timeZone = 0,
const OFBool  normalize = OFTrue 
)

set the time to the specified number of seconds

Parameters:
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
Returns:
OFTrue if the new value is valid and has been set, OFFalse otherwise

OFBool OFTime::setTimeInHours ( const double  hours,
const double  timeZone = 0,
const OFBool  normalize = OFTrue 
)

set the time to the specified number of hours

Parameters:
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
Returns:
OFTrue if the new value is valid and has been set, OFFalse otherwise

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.

Returns:
OFTrue if the current system time has been set, OFFalse otherwise

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 "HH:MM[:SS]" (with arbitrary delimiters) and "HHMM[SS]" (without delimiters) where the brackets enclose optional parts. The optional fractional part of a second and the time zone (see getISO...) are not yet supported.

Parameters:
formattedTime ISO formatted time value to be set
Returns:
OFTrue if input is valid and result variable has been set, OFFalse otherwise

unsigned int OFTime::getHour (  )  const

get the currently stored hour value

Returns:
hour value (might be invalid, i.e. out of range)

unsigned int OFTime::getMinute (  )  const

get the currently stored minute value

Returns:
minute value (might be invalid, i.e. out of range)

double OFTime::getSecond (  )  const

get the currently stored second value

Returns:
second value (might be invalid, i.e. out of range)

unsigned int OFTime::getIntSecond (  )  const

get the integral part of the currently stored second value

Returns:
second value (might be invalid, i.e. out of range)

unsigned int OFTime::getMilliSecond (  )  const

get the milli second part of the currently stored second value

Returns:
milli second part (0..999)

unsigned int OFTime::getMicroSecond (  )  const

get the micro second part of the currently stored second value

Returns:
micro second part (0..999999)

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

Returns:
time zone value (might be invalid, i.e. out of range)

double OFTime::getTimeInSeconds ( const OFBool  useTimeZone = OFFalse,
const OFBool  normalize = OFTrue 
) const

get the currently stored time in seconds

Parameters:
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
Returns:
number of seconds since "00:00:00"

double OFTime::getTimeInHours ( const OFBool  useTimeZone = OFFalse,
const OFBool  normalize = OFTrue 
) const

get the currently stored time in hours.

Parameters:
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
Returns:
number of hours since "00:00:00" (incl. fraction of hours)

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

Returns:
time object with the UTC corrected time set

OFTime OFTime::getLocalTime (  )  const

get the currently stored time in local time.

The resulting time object always has the local time zone.

Returns:
time object with the corrected time set

OFBool OFTime::getISOFormattedTime ( OFString formattedTime,
const OFBool  showSeconds = OFTrue,
const OFBool  showFraction = OFFalse,
const OFBool  showTimeZone = OFFalse,
const OFBool  showDelimiter = OFTrue 
) const

get the current time value in ISO format.

The two ISO time formats supported by this function are "HH:MM[:SS[.FFFFFF]][&ZZ:ZZ]" (with delimiters) and "HHMM[SS[.FFFFFF]][&ZZZZ]" (without delimiters, useful for DICOM time type) where the brackets enclose optional parts.

Parameters:
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
Returns:
OFTrue if result variable has been set, OFFalse otherwise

static OFTime OFTime::getCurrentTime (  )  [static]

get the current system time

Returns:
time object with the current system time set

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

Returns:
local time zone if available, 0 otherwise

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.

Parameters:
tt current system time (as returned by the time() function )
Returns:
OFTrue if the current system time has been set, OFFalse otherwise

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,+12.0] for 'timeZone'

Parameters:
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
Returns:
OFTrue if the current value is valid, OFFalse otherwise

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.

Parameters:
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
Returns:
number of seconds since "00:00:00"

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.

Parameters:
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
Returns:
number of hours since "00:00:00" (incl. fraction of hours)


The documentation for this class was generated from the following file:


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1