SMART on FHIR Python Client 4.2.0
 
Loading...
Searching...
No Matches
fhirclient.models.fhirdatetime.FHIRDateTime Class Reference

A convenience class for working with FHIR datetimes in Python. More...

Inheritance diagram for fhirclient.models.fhirdatetime.FHIRDateTime:
fhirclient.models.fhirdate.FHIRDate

Public Member Functions

 __init__ (self, Union[str, None] jsonval=None)
 
- Public Member Functions inherited from fhirclient.models.fhirdate.FHIRDate
 __setattr__ (self, prop, value)
 
 with_json (cls, Union[str, list] jsonobj)
 Initialize a date from an ISO date string.
 
 with_json_and_owner (cls, Union[str, list] jsonobj, owner)
 Added for compatibility reasons to FHIRElement; "owner" is discarded.
 
Union[str, None] as_json (self)
 Returns the original JSON string used to create this instance.
 

Static Protected Member Functions

Any _from_string (str value)
 
- Static Protected Member Functions inherited from fhirclient.models.fhirdate.FHIRDate
 _parse_partial (str value, cls)
 Handle partial dates like 1970 or 1980-12.
 
datetime.date _parse_date (str value)
 
datetime.datetime _parse_datetime (str value)
 
datetime.time _parse_time (str value)
 
str _strip_leap_seconds (str value)
 Manually ignore leap seconds by clamping the seconds value to 59.
 

Static Protected Attributes

 _REGEX
 Private properties and methods #.
 
str _FIELD
 
- Static Protected Attributes inherited from fhirclient.models.fhirdate.FHIRDate
 _REGEX
 Private properties and methods #.
 
str _FIELD
 

Additional Inherited Members

- Public Attributes inherited from fhirclient.models.fhirdate.FHIRDate
 date
 
 origval
 
- Protected Attributes inherited from fhirclient.models.fhirdate.FHIRDate
 _FIELD
 
- Properties inherited from fhirclient.models.fhirdate.FHIRDate
 isostring = property
 Returns a standardized ISO 8601 version of the Python representation of the FHIR JSON.
 

Detailed Description

A convenience class for working with FHIR datetimes in Python.

http://hl7.org/fhir/R4/datatypes.html#datetime

Converting to a Python representation does require some compromises:

  • This class will convert partial dates ("reduced precision dates") like "2024" into full naive datetimes using the earliest possible time (in this example, "2024-01-01T00:00:00") because Python's datetime class does not support partial dates.
  • FHIR allows arbitrary sub-second precision, but Python only holds microseconds.
  • Leap seconds (:60) will be changed to the 59th second (:59) because Python's time classes do not support leap seconds.

If such compromise is not useful for you, avoid using the date, datetime, or isostring properties and just use the as_json() method in order to work with the original, exact string.

Public properties:

  • datetime: datetime.datetime representing the JSON value (naive or aware)
  • date: backwards-compatibility alias for datetime
  • isostring: an ISO 8601 string version of the above Python object

Public methods:

  • as_json: returns the original JSON used to construct the instance

Constructor & Destructor Documentation

◆ __init__()

fhirclient.models.fhirdatetime.FHIRDateTime.__init__ (   self,
Union[str, None]   jsonval = None 
)

Member Function Documentation

◆ _from_string()

Any fhirclient.models.fhirdatetime.FHIRDateTime._from_string ( str  value)
staticprotected

Member Data Documentation

◆ _FIELD

fhirclient.models.fhirdatetime.FHIRDateTime._FIELD
staticprotected

◆ _REGEX

fhirclient.models.fhirdatetime.FHIRDateTime._REGEX
staticprotected

Private properties and methods #.


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