On Tue, Apr 13, 2010 at 12:35 PM, John Williams <willi...@tni.com> wrote:

>
>> Asking for the latest prior Sunday or any other weekday is a useful
>> function, but it doesn't really have anything to do with 'truncation'.
>>
>
> Asking for the first of the month is truncating to an even more arbitrary
> interval than a seven-day period, but we still call it truncation somehow.\
>

The size of the unit (and that size's variability) wasn't my point; it's
that the unit is part of the fundamental identity of the date. A date is not
a day; it's a particular name for a day.  So when you truncate it, what you
are removing precision from is the name.  If the end result doesn't look
like part of the name, it's not truncation.  IMESHO, of course.

The only reason you can "truncate" to the week in the proposed DateTime is
because it includes support for the ISO week-based calendar, in additiion to
the Gregorian.  So just as you can truncate the Gregorian date "April 13,
2010" to "April 2010" or to "2010",  you can truncate the ISO 8601 date
"2010W15-2" to "2010W15" or to "2010".  In each case the result of the
truncation is the first day of the named period, which in the case of the
ISO week calendar happens to be a Monday, but the truncation actually
represents the whole period - just as truncating a real number to an integer
yields a value that logically represents the entire half-open range from
that integer to the next.

You can imagine objects representing dates using other calendar systems.
 Today's Julian date "March 31, 2010" could be truncated to "March 2010" or
to "2010"; the Mayan long count 12.19.17.4.17 could be truncated to unial
12.19.17.4 or tun 12.19.17 or katun 12.19 or baktun 12.  But unless I'm
using a date object that has a "baktun" property, I wouldn't expect to be
able to truncate to the baktun.

The trouble with asking for the prior sunday, is that on sunday an
> implementation of the prior() function will return a date 7 days prior to
> today, while an implementation of the truncate() function will return
> today.
>

True; that's why the Calendrica function is called "kday-on-or-before"
instead of "prior-kday" - or actually, it may have both of those, with the
difference you indicated.  It's all about choosing the right name.  :)

Whatever you call it, it's a valuable function, I'm just arguing that it's
not "truncation" unless you're talking about a calendar where you number
Sunday-based weeks from a given epoch.

-- 
Mark J. Reed <markjr...@gmail.com>

Reply via email to