Documentation
¶
Overview ¶
Package datehelpers provides functions for parsing CQL date, datetime and time strings.
Index ¶
- Variables
- func DateString(d time.Time, precision model.DateTimePrecision) (string, error)
- func DateTimeString(d time.Time, precision model.DateTimePrecision) (string, error)
- func ParseDate(rawStr string, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
- func ParseDateTime(rawStr string, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
- func ParseFHIRDate(d *d4pb.Date, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
- func ParseFHIRDateTime(d *d4pb.DateTime, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
- func ParseTime(rawStr string, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
- func TimeString(d time.Time, precision model.DateTimePrecision) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedPrecision = errors.New("unsupported precision")
ErrUnsupportedPrecision is returned when a precision is not supported.
Functions ¶
func DateString ¶
DateString returns a CQL Date string representation of a Date.
func DateTimeString ¶
DateTimeString returns a CQL DateTime string representation of a DateTime.
func ParseDate ¶
func ParseDate(rawStr string, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
ParseDate parses a CQL Date string into a golang time. CQL Dates start with @ and follow a subset of ISO-8601.
CQL Dates do not have timezone offsets, but when converting a Date to a DateTime the offset of the evaluation timestamp is used. Since all golang times require a location we set all Date offset to the offset of the evaluation timestamp.
func ParseDateTime ¶
func ParseDateTime(rawStr string, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
ParseDateTime parses a CQL DateTime string into a golang time. CQL Dates start with @ and follow a subset of ISO-8601. If rawStr does not include an offset then evaluationLoc will be used. Otherwise, the offset in rawStr is used.
func ParseFHIRDate ¶
func ParseFHIRDate(d *d4pb.Date, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
ParseFHIRDate parses a FHIR Date proto into a golang time. Similar to other helpers in this package, if the proto does not have a timezone set then evaluationLoc will be used.
To match ParseDate, we take the year, month, and day values from the FHIR proto (in the FHIR proto's timezone) and create a new time.Time at 0:00:00 in the evaluationLoc timezone, which is the default timezone we attach to all CQL Dates in our codebase.
func ParseFHIRDateTime ¶
func ParseFHIRDateTime(d *d4pb.DateTime, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
ParseFHIRDateTime parses a FHIR DateTime proto into a golang time. Similar to other helpers in this package, if the proto does not have a timezone set then evaluationLoc will be used.
func ParseTime ¶
func ParseTime(rawStr string, evaluationLoc *time.Location) (time.Time, model.DateTimePrecision, error)
ParseTime parses a CQL Time string into a golang time. CQL Time start with @ and roughly follow ISO-8601.
func TimeString ¶
TimeString returns a CQL Time string representation of a Time.
Types ¶
This section is empty.