Question
Julian Matthews · Apr 1, 2021

Syntax for datetime conversions from UTC

Hey everyone.

I'm attempting to convert a date from UTC to my locale, and for some reason I can't seem to get the Ensemble ConvertDateTime Utility Function to detect the timezone to then convert. I'm hoping it's just a syntax issue, and that someone can show me the error of my ways.

The date format is YYYYMMDDHHmmss+0000 (so for example, 20210401102030+0000)

I was expecting that setting the informat to "%q%z" would mean that the %z picks up the +0000 as UTC, but it doesn't seem to make a difference. The only way I've been able to make this work is by using %K(0) at the start of the informat to explicitly state that it is UTC, but I feel that it's an easy way out.

Any pointers are greatly appreciated.

Product version:
IRIS 2019.1
00
2 0 2 48
Log in or sign up to continue

Replies

Have you tried %K(Server) as the output format prefix?

HICG>set tm="20210401072630+0000"
HICG>w ##class(Ens.Util.FunctionSet).ConvertDateTime(tm,"%q%z","%K(Server)%q%z")
20210401032630-0400
This of course assumes your server is in your locale/time zone.

Hey Jeffrey.

That's done the trick - I wrongly assumed that not specifying the locale in the outformat would assume the current locale.

Thank you for your help!