FHIR Chat · Why doesn't DateTime convert to Time? · implementers

Stream: implementers

Topic: Why doesn't DateTime convert to Time?


view this post on Zulip Preston TW (Mar 10 2020 at 23:00):

Hello all!

I'm trying to separate out a DateTime into both a Date and a Time. It looks like I can go from a DT -> D (http://hl7.org/fhirpath/2018Sep/index.html#todate-date), but it doesn't look like I can go from a DT -> T (http://hl7.org/fhirpath/2018Sep/index.html#totime-time). The alternative seems to turn the DT into a string, then split, then turn that string into a time (which is not ergonomic to me).

Is there an easier way to do this?

Thank you,
Preston

view this post on Zulip Lloyd McKenzie (Mar 10 2020 at 23:02):

@Bryn Rhodes

view this post on Zulip Bryn Rhodes (Mar 10 2020 at 23:29):

@Preston TW , operators to support date/time component extraction didn't make the cut in the first round, so we don't have a first-class way to do this. There's a thread here that suggests using a .toString().substring().toTime() approach. I've also logged a tracker J#26554.

view this post on Zulip Preston TW (Mar 11 2020 at 00:00):

Thanks @Bryn Rhodes , it seemed a little inconsistent to me to have a toDate method for DateTime but not a toTime method. In the meantime I'll use the substring approach.

Thank you!


Last updated: Apr 12 2022 at 19:14 UTC