# RE: order relation of timeDuration [let timeDuration be a union]

```I would second that the current algorithm for comparing time durations is a nightmare.  My suggestion in http://lists.w3.org/Archives/Public/www-xml-schema-comments/2000JanMar/0073.html was, for the purpose of evaluating min and max constraints, was to make 1 month and 2629746 seconds equivalent (based on an average length of month in a 400 year calendar cycle).  I thought and still think that was a very reasonable algorithm for comparing timeDurations.

Union types weren't in schema back when I made that suggestion, however it might be reasonable to rethink timeDuration in terms of a union.  There seems to be vanishingly small value to be able to specify a time duration with both a precise and imprecise part such as "P1MT12S".  However there is value to be able to have one type that would allow a rental period, for example, to be P1D, P1M or P1Y, PT1H.

This could be accomplished by having timeDuration be a union of two other types, timeDurationMonths and timeDurationSeconds.

The value space of timeDurationMonths would be an integer number of months, the lexical representation would be "[-]P[nY][nM]".  The canonical representation would be "[-]PnM".  1Y is exactly 12M.

The value space of timeDuruationSeconds would be a IEEE double of seconds, the lexical representation would be "[-]P[1D]T[nH][nM][n[.nnnn]S".  The canonical representation would be "[-]Pn.nnnS" (no trailing zeros, no leading zeros except immediately to the left of the decimal).  One D would be exactly 24H, 1H exactly 60M and 1M exactly 60S, no account for leap seconds or the like.

If you wanted to enforce a min/max constraint, you would need to restrict one or the other of these atomic types.

If you wanted to have a timeDuration that could either be precise or imprecise, you could use timeDuration which would be a union of these type atomic types.  However, you would not be able to constrain a derived type with a min or max constraint.

This approach also eliminates this one odd-ball type whose value space was a duple of a integer count of months and a double count of seconds (at least that is better than considering it a six-deminsion space).  timeDuration is just a union of two atomic types.
```

Received on Friday, 9 February 2001 02:20:46 UTC