Re: [xslt] Problem with date:seconds


> I think the interpretation in 1.0.20 makes more sense.
> In 
> they use the word "difference" and I think this is
> not very exact.
> The difference between 1 and 2 is 1;
> the difference between 2 and 1 is also 1 (not -1).

No. The difference between 1 and 2 is -1.

The difference in mathematical sense is the result of a subtraction and a 
subtraction is not comutative, means x-y != y-x. The difference in the sense 
of "distance", which cannot be negative, is what you are looking for.

The documentation for date:seconds says:
   "...the difference between the date/time string and 1970-01-01T00:00:00Z 
is calculated as with date:difference..."

The documentation for date:difference says:
   "...If the first date occurs before the second date, then the result is a 
positive duration; if it occurs after the second date, the result is a 
negative duration."

Your date, somewhen anno 2002, is the first date and 1.1.1970 is the second, 
that is what the first quote says. The second quote says that date:seconds 
returns a negative value for everything that occurs after 1.1.1970. By doing 
exactly that, libxslt follows the EXSLT specification.

Having said that, I must also say that I believe that the specification for 
date:difference is wrong. Math says:

   x - y is
              1.)  > 0 iff x > y
              2.)  < 0 iff x < y
              3.)  = 0 iff x = y

If we imagine the time on an axis, any human will percept the growth towards 
the future. The specification for date:difference agrees to this only in 
case 3. It assumes that "past > future", which heretises the human logic and 
perception of time. Ask anyone to compare two data and you'll hear that the 
former is smaller than the latter.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]