DCMTK  Version 3.6.1 20120515
OFFIS DICOM Toolkit
Public Member Functions | Static Public Member Functions
DcmTime Class Reference

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

+ Inheritance diagram for DcmTime:

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)


Constructor & Destructor Documentation

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

constructor.

Create new element from given tag and length.

Parameters:
tagDICOM tag for the new element
lenvalue length for the new element
DcmTime::DcmTime ( const DcmTime old)

copy constructor

Parameters:
oldelement to be copied

Member Function Documentation

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:
valuestring value to be checked (possibly multi-valued)
vmvalue multiplicity (according to the data dictionary) to be checked for. (See DcmElement::checkVM() for a list of valid values.)
oldFormatsupport 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
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:
vmvalue multiplicity (according to the data dictionary) to be checked for. (See DcmElement::checkVM() for a list of valid values.)
oldFormatsupport 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 DcmObject* DcmTime::clone ( ) const [inline, virtual]

clone method

Returns:
deep copy of this object

Reimplemented from DcmByteString.

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.

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:
dicomTimereference to string variable where the result is stored
secondsadd optional seconds ("SS") if OFTrue
fractionadd 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:
timeValuetime to be converted to DICOM format
dicomTimereference to string variable where the result is stored
secondsadd optional seconds ("SS") if OFTrue
fractionadd 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::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 or the current element value is empty, 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:
formattedTimereference to string variable where the result is stored
posindex of the element component in case of value multiplicity (0..vm-1)
secondsadd optional seconds (":SS") if OFTrue
fractionadd optional fractional part of a second (".FFFFFF") if OFTrue (requires parameter 'seconds' to be also OFTrue)
createMissingPartif OFTrue create optional parts (seconds and/or fractional part of a seconds) if absent in the element value
supportOldFormatif 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 or the specified DICOM time value is empty, the result variable 'formattedTime' is cleared automatically.

Parameters:
dicomTimestring value in DICOM TM format to be converted to ISO format
formattedTimereference to string variable where the result is stored
secondsadd optional seconds (":SS") if OFTrue
fractionadd optional fractional part of a second (".FFFFFF") if OFTrue (requires parameter 'seconds' to be also OFTrue)
createMissingPartif OFTrue create optional parts (seconds and/or fractional part of a seconds) if absent in the DICOM TM value
supportOldFormatif OFTrue support old (prior V3.0) time format (see above)
Returns:
EC_Normal upon success, an error code otherwise
virtual OFCondition DcmTime::getOFString ( OFString stringValue,
const unsigned long  pos,
OFBool  normalize = OFTrue 
) [virtual]

get a copy of a particular string component

Parameters:
stringValuevariable in which the result value is stored
posindex of the value in case of multi-valued elements (0..vm-1)
normalizedelete trailing spaces if OFTrue
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmByteString.

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:
timeValuereference to OFTime variable where the result is stored
posindex of the element component in case of value multiplicity (0..vm-1)
supportOldFormatif OFTrue support old (prior V3.0) time format (see above)
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:
dicomTimestring value in DICOM TM format to be converted to ISO format. An empty string is not regarded as valid input, since the time would be unknown.
timeValuereference to OFTime variable where the result is stored
supportOldFormatif 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:
dicomTimeZonestring value in DICOM format ("&ZZZZ") to be converted
timeZonereference to floating point variable where the resulting UTC offset is stored
Returns:
EC_Normal upon success, an error code otherwise
virtual DcmEVR DcmTime::ident ( ) const [virtual]

get element type identifier

Returns:
type identifier of this class (EVR_TM)

Reimplemented from DcmByteString.

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

assignment operator

Parameters:
objelement to be assigned/copied
Returns:
reference to this object
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:
secondsadd optional seconds ("SS") if OFTrue
fractionadd 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:
timeValuetime to be set (should be a valid time)
Returns:
EC_Normal upon success, an error code otherwise

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


Generated on Tue May 15 2012 for DCMTK Version 3.6.1 20120515 by Doxygen 1.7.5.1-20111027