8

I'm trying to determine what the default time zone is for an XML Schema dateTime, when it is not specific. The time zone portion at the end is optional and it may be omitted:

2013-01-11T16:02:55

I read in this answer that the time zone is undetermined when not specified. I read in the comments to this question that the default is UTC if not specified. I also read through the W3C definition and that didn't give me a clear answer.

Can any experts point me to where this is specified?

Community
  • 1
  • 1
mek363
  • 415
  • 1
  • 4
  • 13

2 Answers2

14

An unspecified time zone is exactly that - unspecified. No more, no less. It's not saying it's in UTC, nor is it saying it's in the local time zone or any other time zone, it's just saying that the time read from some clock somewhere was that time.

The fact that it originated from an xs:dateTime doesn't really play into it at all. It's just an ISO 8601 date + time (without time zone) value.

It really depends on what you do with this value as to what it actually means.

In the real world, you probably should avoid values like this when working with timestamps - that is, the exact moment something occurs. For those you should specify an offset like -07:00, or a Z to indicate UTC.

Where an unspecified value might have legitimate usage:

  • When scheduling future events by recurrence pattern, and paired with a time zone (such as America/New_York). For details, see other answers of mine here, here, and here.

  • When referring to a "floating" time, that might be at a different instantaneous moment in multiple time zones. Example: A network television show that starts at 7:00 PM. The Eastern US would see it before the Western US, but it still airs at the same "floating" time in each zone.

  • When the time zone is already known by some other mechanism, and there is no risk of daylight saving time ambiguity, or when the risk is accepted and determined inconsequential.

Community
  • 1
  • 1
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • Right, I understand what "unspecified" means, but I was first trying to confirm whether the assertion that "default is UTC if not specified" was true. I can look more into 8601, but the XML Schema spec stops short of saying it uses 8601 strictly. For example, "The date and time datatypes described in this recommendation were _inspired by_ [ISO 8601]." – mek363 Dec 19 '13 at 14:35
  • It's interesting that the [Wikipedia article](http://en.wikipedia.org/wiki/ISO_8601) about 8601 says "If no UTC relation information is given with a time representation, the time is assumed to be in local time." – mek363 Dec 19 '13 at 14:38
  • The wording in that particular sentence in the Wikipedia article is slightly misleading. The sentence right above it is better: "... are represented as local time (with the location unspecified) ...". Another way to think about it is "**A** local time" vs "**THE** local time". In other words, "local" doesn't necessarily mean *your* local, it could be someone else's local. – Matt Johnson-Pint Dec 19 '13 at 15:13
  • You are correct on the point that W3C XSD isn't an *exact* match to ISO 8601, but it does heavily rely on it. This is discussed in the spec [in Appendix D](http://www.w3.org/TR/xmlschema-2/#isoformats), and also shows how it deviates. Nowhere can I find it say that UTC is inferred as a default. – Matt Johnson-Pint Dec 19 '13 at 15:18
  • By the ISO Spec (ISO8601:2004E) section 4.3.2 contains this bit "The zone designator is empty if use is made of local time ...", and "local time" is defined by section 2.1.16 as "locally applicable time of day such as standard time of day, or a non-UTC based time of day". Again, it doesn't say *whose local* it is - just that it's a non-UTC value that is locally applicable *somewhere*. – Matt Johnson-Pint Dec 19 '13 at 15:24
4

In XSD 1.0, sec. 3.2.7 says (sec. "untimezoned times are presumed to be the time in the timezone of some unspecified locality". That seems to me a pretty clear indication that they don't default to UTC for validation purposes, and also that they don't default to local time for any fixed locality (e.g. the server's time). Sec. 3.2.7.4 describes (in some detail and at tedious length) that the ordering relation on dateTime is a partial order, not a total order, because (for example) the untimezoned value 2000-01-20T12:00:00 is neither definitely earlier than, nor definitely later than, nor definitely equal to, 2000-01-20T12:00:00Z.

XSD 1.1 revises the text of the discussion a good deal, but it comes to the same thing.

I believe that this is consistent with the rules in ISO 8601.

What an application makes of untimezoned values, and what other specs do with them, is a separate issue, to be answered application by application and spec by spec. But for XSD purposes, it's clear that there is no default timezone.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65