[
Lists Home |
Date Index |
Thread Index
]
Hi Jeff,
> It seems there's something wrong with the pinning algorithm.
> Probably, there should be an attempt to do pinning only at the end
> of the computation (by analogy with rounding) -- the idea of pinning
> to a valid date after adding Y/M components, then later dealing with
> the day and time parts seems of dubious merit.
Agreed that it's something wrong with the pinning algorithm, but I
don't think that leaving the pinning until the end works either.
We're trying to find an algorithm where following is true:
2004-01-29T12:00:00 + P1M <
2004-01-30T00:00:00 + P1M <
2004-01-30T12:00:00 + P1M <
2004-01-31T00:00:00 + P1M <
2004-01-31T12:00:00 + P1M <
2004-02-01T00:00:00 + P1M
It seems obvious that 2004-01-29T12:00:00 + P1M => 2004-02-29T12:00:00
and that 2004-02-01T00:00 => 2004-03-01T00:00:00. Which means that we
need to find something where the following is true:
2004-02-29T12:00:00 <
2004-01-30T00:00:00 + P1M <
2004-01-30T12:00:00 + P1M <
2004-01-31T00:00:00 + P1M <
2004-01-31T12:00:00 + P1M <
2004-03-01T00:00:00
And now things are difficult, to say the least. If the days are pinned
back then 2004-01-29T12:00:00 + P1M < 2004-01-30T00:00:00 + P1M
won't be true. If they're rounded up, then 2004-01-31T12:00:00 + P1M <
2004-02-01T00:00:00 + P1M won't be true. In either case, keeping the
relationship 2004-01-30T12:00:00 + P1M < 2004-01-31T00:00:00 + P1M is
going to be hard.
It's not just a matter of the times causing problems, or that it's a
leap year causing the difficulty. There are similar issues with:
2002-01-28 + P1M <
2002-01-29 + P1M <
2002-01-30 + P1M <
2002-01-31 + P1M <
2002-02-01 + P1M
Hmm... The thing is that adding durations to date/times is a useful
thing to do, so I'd be loath to make it impossible in XPath 2.0. If it
were done through a function call instead, that would enable the +
operator to retain its usual semantics. What do you think? Would it
matter if:
2002-01-28 < 2002-01-30
but not:
add-yearMonthDuration-to-date(
xs:date('2002-01-28'), xs:yearMonthDuration('P1M')) <
add-yearMonthDuration-to-date(
xs:date('2002-01-30'), xs:yearMonthDuration('P1M'))
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
|