DcmTime Class Reference

a class representing the DICOM value representation 'Time' (TM) More...

Inheritance diagram for DcmTime:

DcmByteString DcmElement DcmObject List of all members.

Public Member Functions

 DcmTime (const DcmTag &tag, const Uint32 len=0)
 constructor.
 DcmTime (const DcmTime &old)
 copy constructor
virtual ~DcmTime ()
 destructor
DcmTimeoperator= (const DcmTime &obj)
 assignment operator
virtual DcmObjectclone () const
 clone method
virtual OFCondition copyFrom (const DcmObject &rhs)
 Virtual object copying.
virtual DcmEVR ident () const
 get element type identifier
virtual OFCondition checkValue (const OFString &vm="1-n", const OFBool oldFormat=OFFalse)
 check whether stored value conforms to the VR and to the specified VM
virtual OFCondition getOFString (OFString &stringValue, const unsigned long pos, OFBool normalize=OFTrue)
 get a copy of a particular string component
OFCondition setCurrentTime (const OFBool seconds=OFTrue, const OFBool fraction=OFFalse)
 set the element value to the current system time.
OFCondition setOFTime (const OFTime &timeValue)
 set the element value to the given time
OFCondition getOFTime (OFTime &timeValue, const unsigned long pos=0, const OFBool supportOldFormat=OFTrue)
 get the current element value in OFTime format.
OFCondition getISOFormattedTime (OFString &formattedTime, const unsigned long pos=0, const OFBool seconds=OFTrue, const OFBool fraction=OFFalse, const OFBool createMissingPart=OFFalse, const OFBool supportOldFormat=OFTrue)
 get the current element value in ISO time format.

Static Public Member Functions

static OFCondition getCurrentTime (OFString &dicomTime, const OFBool seconds=OFTrue, const OFBool fraction=OFFalse)
 get the current system time.
static OFCondition getDicomTimeFromOFTime (const OFTime &timeValue, OFString &dicomTime, const OFBool seconds=OFTrue, const OFBool fraction=OFFalse)
 get the specified OFTime value in DICOM format.
static OFCondition getOFTimeFromString (const OFString &dicomTime, OFTime &timeValue, const OFBool supportOldFormat=OFTrue)
 get the specified DICOM time value in OFTime format.
static OFCondition getISOFormattedTimeFromString (const OFString &dicomTime, OFString &formattedTime, const OFBool seconds=OFTrue, const OFBool fraction=OFFalse, const OFBool createMissingPart=OFFalse, const OFBool supportOldFormat=OFTrue)
 get the specified DICOM time value in ISO format.
static OFCondition getTimeZoneFromString (const OFString &dicomTimeZone, double &timeZone)
 get the specified DICOM time zone in number of hours format DICOM standard states that if the "Timezone Offset From UTC" attribute (0008,0201) is present it applies to all TM attributes in the object.
static OFCondition checkStringValue (const OFString &value, const OFString &vm="1-n", const OFBool oldFormat=OFFalse)
 check whether given string value conforms to the VR "TM" (Time) and to the specified VM.

Detailed Description

a class representing the DICOM value representation 'Time' (TM)

Definition at line 41 of file dcvrtm.h.


Constructor & Destructor Documentation

DcmTime::DcmTime ( const DcmTag tag,
const Uint32  len = 0 
)

constructor.

Create new element from given tag and length.

Parameters:
tag DICOM tag for the new element
len value length for the new element

Referenced by clone().

DcmTime::DcmTime ( const DcmTime old  ) 

copy constructor

Parameters:
old element to be copied


Member Function Documentation

DcmTime& DcmTime::operator= ( const DcmTime obj  ) 

assignment operator

Parameters:
obj element to be assigned/copied
Returns:
reference to this object

virtual DcmObject* DcmTime::clone (  )  const [inline, virtual]

clone method

Returns:
deep copy of this object

Reimplemented from DcmByteString.

Definition at line 73 of file dcvrtm.h.

References DcmTime().

virtual OFCondition DcmTime::copyFrom ( const DcmObject rhs  )  [virtual]

Virtual object copying.

This method can be used for DcmObject and derived classes to get a deep copy of an object. Internally the assignment operator is called if the given DcmObject parameter is of the same type as "this" object instance. If not, an error is returned. This function permits copying an object by value in a virtual way which therefore is different to just calling the assignment operator of DcmElement which could result in slicing the object.

Parameters:
rhs - [in] The instance to copy from. Has to be of the same class type as "this" object
Returns:
EC_Normal if copying was successful, error otherwise

Reimplemented from DcmByteString.

virtual DcmEVR DcmTime::ident (  )  const [virtual]

get element type identifier

Returns:
type identifier of this class (EVR_TM)

Reimplemented from DcmByteString.

virtual OFCondition DcmTime::checkValue ( const OFString vm = "1-n",
const OFBool  oldFormat = OFFalse 
) [virtual]

check whether stored value conforms to the VR and to the specified VM

Parameters:
vm value multiplicity (according to the data dictionary) to be checked for. (valid values: "1", "1-2", "1-3", "1-8", "1-99", "1-n", "2", "2-n", "2-2n", "3", "3-n", "3-3n", "4", "6", "9", "16", "32")
oldFormat support old ACR/NEMA format if OFTrue (':' as a separator)
Returns:
status of the check, EC_Normal if value is correct, an error code otherwise

Reimplemented from DcmElement.

virtual OFCondition DcmTime::getOFString ( OFString stringValue,
const unsigned long  pos,
OFBool  normalize = OFTrue 
) [virtual]

get a copy of a particular string component

Parameters:
stringValue variable in which the result value is stored
pos index of the value in case of multi-valued elements (0..vm-1)
normalize delete trailing spaces if OFTrue
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmByteString.

OFCondition DcmTime::setCurrentTime ( const OFBool  seconds = OFTrue,
const OFBool  fraction = OFFalse 
)

set the element value to the current system time.

The DICOM TM format supported by this function is "HHMM[SS[.FFFFFF]]" where the brackets enclose optional parts. If the current system time or parts of it are unavailable the corresponding values are set to "0" and an error code is returned.

Parameters:
seconds add optional seconds ("SS") if OFTrue
fraction add optional fractional part of a second (".FFFFFF") if OFTrue (requires parameter 'seconds' to be also OFTrue)
Returns:
EC_Normal upon success, an error code otherwise

OFCondition DcmTime::setOFTime ( const OFTime timeValue  ) 

set the element value to the given time

Parameters:
timeValue time to be set (should be a valid time)
Returns:
EC_Normal upon success, an error code otherwise

OFCondition DcmTime::getOFTime ( OFTime timeValue,
const unsigned long  pos = 0,
const OFBool  supportOldFormat = OFTrue 
)

get the current element value in OFTime format.

Please note that the element value is expected to be in valid DICOM TM format ("[HH[MM[SS[.FFFFFF]]]]", "[HH[:MM[:SS[.FFFFFF]]]]" is also supported for reasons of backward compatibility). Since there is no time zone for the DICOM TM format local time is assumed (the time zone of 'timeValue' is set automatically). If this function fails the result variable 'timeValue' is cleared automatically.

Parameters:
timeValue reference to OFTime variable where the result is stored
pos index of the element component in case of value multiplicity (0..vm-1)
supportOldFormat if OFTrue support old (prior V3.0) time format (see above)
Returns:
EC_Normal upon success, an error code otherwise

OFCondition DcmTime::getISOFormattedTime ( OFString formattedTime,
const unsigned long  pos = 0,
const OFBool  seconds = OFTrue,
const OFBool  fraction = OFFalse,
const OFBool  createMissingPart = OFFalse,
const OFBool  supportOldFormat = OFTrue 
)

get the current element value in ISO time format.

The ISO time format supported by this function is "HH:MM[:SS[.FFFFFF]]" where the brackets enclose optional parts. Please note that the element value is expected to be in valid DICOM TM format ("[HH[MM[SS[.FFFFFF]]]]", "[HH[:MM[:SS[.FFFFFF]]]]" is also supported for reasons of backward compatibility). If this function fails the result variable 'formattedTime' is cleared automatically. Please note that if the "Timezone Offset From UTC" attribute (0008,0201) is present, it applies to all TM attributes in the object. However, the time zone is not taken into account for the creation of the ISO formatted time. See also "getTimeZoneFromString()" below.

Parameters:
formattedTime reference to string variable where the result is stored
pos index of the element component in case of value multiplicity (0..vm-1)
seconds add optional seconds (":SS") if OFTrue
fraction add optional fractional part of a second (".FFFFFF") if OFTrue (requires parameter 'seconds' to be also OFTrue)
createMissingPart if OFTrue create optional parts (seconds and/or fractional part of a seconds) if absent in the element value
supportOldFormat if OFTrue support old (prior V3.0) time format (see above)
Returns:
EC_Normal upon success, an error code otherwise

static OFCondition DcmTime::getCurrentTime ( OFString dicomTime,
const OFBool  seconds = OFTrue,
const OFBool  fraction = OFFalse 
) [static]

get the current system time.

The DICOM TM format supported by this function is "HHMM[SS[.FFFFFF]]" where the brackets enclose optional parts. If the current system time or parts of it are unavailable the corresponding values are set to "0" and an error code is returned.

Parameters:
dicomTime reference to string variable where the result is stored
seconds add optional seconds ("SS") if OFTrue
fraction add optional fractional part of a second (".FFFFFF") if OFTrue (requires parameter 'seconds' to be also OFTrue)
Returns:
EC_Normal upon success, an error code otherwise

static OFCondition DcmTime::getDicomTimeFromOFTime ( const OFTime timeValue,
OFString dicomTime,
const OFBool  seconds = OFTrue,
const OFBool  fraction = OFFalse 
) [static]

get the specified OFTime value in DICOM format.

The DICOM TM format supported by this function is "HHMM[SS[.FFFFFF]]" where the brackets enclose optional parts. If the current system time or parts of it are unavailable the corresponding values are set to "0" and an error code is returned.

Parameters:
timeValue time to be converted to DICOM format
dicomTime reference to string variable where the result is stored
seconds add optional seconds ("SS") if OFTrue
fraction add optional fractional part of a second (".FFFFFF") if OFTrue (requires parameter 'seconds' to be also OFTrue)
Returns:
EC_Normal upon success, an error code otherwise

static OFCondition DcmTime::getOFTimeFromString ( const OFString dicomTime,
OFTime timeValue,
const OFBool  supportOldFormat = OFTrue 
) [static]

get the specified DICOM time value in OFTime format.

Please note that the element value is expected to be in valid DICOM TM format ("[HH[MM[SS[.FFFFFF]]]]", "[HH[:MM[:SS[.FFFFFF]]]]" is also supported for reasons of backward compatibility). Since there is no time zone for the DICOM TM format local time is assumed (the time zone of 'timeValue' is set automatically). If this function fails the result variable 'timeValue' is cleared automatically.

Parameters:
dicomTime string value in DICOM TM format to be converted to ISO format
timeValue reference to OFTime variable where the result is stored
supportOldFormat if OFTrue support old (prior V3.0) time format (see above)
Returns:
EC_Normal upon success, an error code otherwise

static OFCondition DcmTime::getISOFormattedTimeFromString ( const OFString dicomTime,
OFString formattedTime,
const OFBool  seconds = OFTrue,
const OFBool  fraction = OFFalse,
const OFBool  createMissingPart = OFFalse,
const OFBool  supportOldFormat = OFTrue 
) [static]

get the specified DICOM time value in ISO format.

The ISO time format supported by this function is "HH:MM[:SS[.FFFFFF]]" where the brackets enclose optional parts. Please note that the specified value is expected to be in valid DICOM TM format ("[HH[MM[SS[.FFFFFF]]]]", "[HH[:MM[:SS[.FFFFFF]]]]" is also supported for reasons of backward compatibility). If this function fails the result variable 'formattedTime' is cleared automatically.

Parameters:
dicomTime string value in DICOM TM format to be converted to ISO format
formattedTime reference to string variable where the result is stored
seconds add optional seconds (":SS") if OFTrue
fraction add optional fractional part of a second (".FFFFFF") if OFTrue (requires parameter 'seconds' to be also OFTrue)
createMissingPart if OFTrue create optional parts (seconds and/or fractional part of a seconds) if absent in the DICOM TM value
supportOldFormat if OFTrue support old (prior V3.0) time format (see above)
Returns:
EC_Normal upon success, an error code otherwise

static OFCondition DcmTime::getTimeZoneFromString ( const OFString dicomTimeZone,
double &  timeZone 
) [static]

get the specified DICOM time zone in number of hours format DICOM standard states that if the "Timezone Offset From UTC" attribute (0008,0201) is present it applies to all TM attributes in the object.

This functions allows to convert the DICOM format ("&ZZZZ" where "&" is "+" or "-" and "ZZZZ" hours and minutes) to a floating point value, e.g. "+1.0" means plus one hour and "-2.5" minus two and a half hour, i.e. 2 hours and 30 minutes. The resulting 'timeZone' value can be used in conjuction with a OFTime object to convert the time to different time zones (e.g. to local time or UTC).

Parameters:
dicomTimeZone string value in DICOM format ("&ZZZZ") to be converted
timeZone reference to floating point variable where the resulting UTC offset is stored
Returns:
EC_Normal upon success, an error code otherwise

static OFCondition DcmTime::checkStringValue ( const OFString value,
const OFString vm = "1-n",
const OFBool  oldFormat = OFFalse 
) [static]

check whether given string value conforms to the VR "TM" (Time) and to the specified VM.

Parameters:
value string value to be checked (possibly multi-valued)
vm value multiplicity (according to the data dictionary) to be checked for. (valid values: "1", "1-2", "1-3", "1-8", "1-99", "1-n", "2", "2-n", "2-2n", "3", "3-n", "3-3n", "4", "6", "9", "16", "32")
oldFormat support old ACR/NEMA time format if OFTrue (i.e. with ":" and "." delimiters)
Returns:
status of the check, EC_Normal if value is correct, an error code otherwise


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