Re: [xsl] Is xs:date('2012-09-10+14:00') less than xs:date('2012-09-11-14:00') ?

Subject: Re: [xsl] Is xs:date('2012-09-10+14:00') less than xs:date('2012-09-11-14:00') ?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Sep 2012 16:37:39 -0400
At 2012-09-17 20:01 +0000, Costello, Roger L. wrote:
Hi Folks,

Why does this expression return true:

xs:date('2012-09-10+14:00') lt xs:date('2012-09-11-14:00')

September 10, 2012 plus 14 hours is less than September 11, 2012 minus 14 hours?

As I calculate it,

September 10, 2012 plus 14 hours is 2:00 PM on September 10, 2012

and

September 11, 2012 minus 14 hours is 10:00 AM on September 10, 2012

No?

No, not at all. Your mistake is that it isn't a calculation.


The +14:00 is not a time delta, it is an indication of where in the world the date you have is found. And I'm not sure +/- 14:00 is allowed ... I think time zones only go up to +/-13:00. Ah, I'm wrong, there is a +14:00, and there is a -12:00, but nothing beyond:

  http://en.wikipedia.org/wiki/UTC%2B14:00
  http://en.wikipedia.org/wiki/UTC-12:00

Let's take an easier example, with two valid time zones:

  2012-09-11-04:00 is September 11, 2012 in the Eastern Time Zone
  2012-09-10+04:00 is September 10, 2012 in the Persian Gulf

September 10, 2012 is still before September 11, 2012

We are still only talking about dates ... you do not have any time component, you only have the time-zone component.

And even adding a time component, let's look at noon in both time zones:

2012-09-10T12:00+04:00 is 32 hours before 2012-09-11T12:00-04:00.

Because when you normalize the time zone to a common time zone:

     2012-09-10T12:00+04:00 is 2012-09-10T08:00UTC
     2012-09-11T12:00-04:00 is 2012-09-11T16:00UTC
     ... which are 32 hours apart

So, the "+/1XX:YY" is only a time zone indicator, not an operand in any arithmetic when comparing dates. It becomes an operand when adjusting the date or time or dateTime value to UTC.

I hope this helps.

. . . . . . . . . Ken

--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread