jsonata-js/jsonata

$formatDateTime(millis, picture [, timezone]) and $parseDateTime(timestamp, picture)

sureshssb07 opened this issue · 1 comments

Hi Team,

Is this below feature available in 2.0.3

$formatDateTime(millis, picture [, timezone]) and $parseDateTime(timestamp, picture)

Note: It is mentioned in issue -> Configurable date formats and time zones #166

Please share the sample query for converting 3 digit month(MAY) into number (5). currently we are trying out with below query and it is not working

$toMillis('10/MAY/2018', '[D]/[MMM]/[Y]') ~> $fromMillis('[D]-[MM]-[Y]')

$formatDateTime() was not implemented as a separate function, but on $toMillis (and its equivalent in $fromMillis()) as you've spotted.

It looks like we might have a bug with regardless to an uppercase month; I believe the picture string should be [MN] in that case.

If you have $toMillis('10/May/2018', '[D]/[MNn]/[Y]') then you get 1525910400000 as expected, but $toMillis('10/MAY/2018', '[D]/[MN]/[Y]') doesn't work (and oddly using May with [MN] does)

If I then add on ~> $fromMillis('[D]-[MN]-[Y]') then I get 10-MAY-2018 so the picture string works correctly on that end.

As a workaround for now you might need to adjust your date before using $toMillis().