|
| __init__ (self, Union[str, None] jsonval=None) |
|
| __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.
|
|
A convenience class for working with FHIR dates in Python.
http://hl7.org/fhir/R4/datatypes.html#date
Converting to a Python representation does require some compromises:
- This class will convert partial dates ("reduced precision dates") like "2024" into full dates using the earliest possible time (in this example, "2024-01-01") because Python's date class does not support partial dates.
If such compromise is not useful for you, avoid using the date
or isostring
properties and just use the as_json()
method in order to work with the original, exact string.
For backwards-compatibility reasons, this class is the parent class of FHIRDateTime, FHIRInstant, and FHIRTime. But they are all separate concepts and in a future major release, they should be split into entirely separate classes.
Public properties:
date
: datetime.date representing the JSON value
isostring
: an ISO 8601 string version of the above Python object
Public methods:
as_json
: returns the original JSON used to construct the instance
str fhirclient.models.fhirdate.FHIRDate._strip_leap_seconds |
( |
str |
value | ) |
|
|
staticprotected |
Manually ignore leap seconds by clamping the seconds value to 59.
Python native times don't support them (at the time of this writing, but also watch
https://bugs.python.org/issue23574). For example, the stdlib's datetime.fromtimestamp()
also clamps to 59 if the system gives it leap seconds.
But FHIR allows leap seconds and says receiving code SHOULD accept them,
so we should be graceful enough to at least not throw a ValueError,
even though we can't natively represent the most-correct time.