fn:format-dateTime without place parameter does not use the system time zone

John Ulric <[email protected]> Fri, 14 May 2021 15:28:20 +0200
Newsgroups gmane.text.xml.saxon.help
Message-ID <CANS5RiefYVGRiBj6+0of1GKs_YoknDm_BGPiZ-umBQ9yS+GOuA@mail.gmail.com>
Hello everyone, is it by intention (or by specification) that fn:formatDate
does *not* use the system default time zone if no explicit place parameter
is given?

See this test against current Saxon-HE 10.5:

@Test
public void testTimeZone() throws SaxonApiException {
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
    XPathCompiler compiler = new
Processor(Configuration.newConfiguration()).newXPathCompiler();
    assertThat(compiler.evaluateSingle("Q{http://www.w3.org/2005/xpath-functions}format-dateTime(xs:dateTime('2021-05-14T22:00:00Z'),
'[Y0001]-[M01]-[D01] [H01][m01]', (), (), ())",
null).getStringValue(),
            is("2021-05-14 2200"));
    assertThat(compiler.evaluateSingle("Q{http://www.w3.org/2005/xpath-functions}format-dateTime(xs:dateTime('2021-05-14T22:00:00Z'),
'[Y0001]-[M01]-[D01] [H01][m01]', (), (), 'Europe/Berlin')",
null).getStringValue(),
            is("2021-05-15 0000")); // good!
    assertThat(compiler.evaluateSingle("Q{http://www.w3.org/2005/xpath-functions}format-dateTime(xs:dateTime('2021-05-14T18:00:00-04:00'),
'[Y0001]-[M01]-[D01] [H01][m01]', (), (), ())",
null).getStringValue(),
            is("2021-05-14 1800"));

}

Berlin in DST is two hours ahead of GMT. The second assertion with
explicit place parameter shows this correctly, displaying the next day
0000 hours. Without a given place, fn:format-dateTime seems to always
display the "wall time" as written in the dateTime value, ie, neither
in GMT nor in the system time zone, but no time zone at all.

I have also noticed that, while the Configuration class does have settings
for the default language and country, and these are automatically
initialized from the system defaults, there is no setting for the default
time zone.

John

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help