iNTERFACEWARE Products Manual > Installing and Using Chameleon > Using Python Scripting > Chameleon Python API > Timestamp Functions |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
In HL7 messages, fields that contain date and time information store it in the following format:
This is interpreted as follows:
The following are all valid date/time formats:
A date/time representation in any of these valid formats is known as a timestamp. To make it easier for you to use timestamps in your Python scripts, Chameleon defines functions that create, process and validate timestamps. The following functions are defined:
To use these functions, you must import the ifware.timestamp module. For example:
The is_timestamp() function performs two types of validation: it checks whether the timestamp is in the proper format, and it checks whether each component of the timestamp is meaningful. For example, the following timestamp is flagged as invalid:
While this timestamp is in the proper format, some of its fields contain values that are not meaningful: the DD (day) field is 32, and the SS (seconds) field is 61. is_timestamp() would flag this timestamp as invalid. Note that parse_timestamp() returns fractions of a second as a decimal fraction (for example, .25 represents a quarter of a second). To return the number of ten-thousandths of a second in the timestamp, you will need to multiply the returned fraction by 10000:
|