[pmwiki-users] Conditional Directive based on time
Patrick R. Michaud
pmichaud at pobox.com
Wed Oct 12 10:38:55 CDT 2005
On Wed, Oct 12, 2005 at 10:33:26AM -0400, Neil Herber wrote:
> >Keeping this theme, then ("through" means "including" here):
> >
> > (:if date 200501-200503 :) 2005.01.01 through 2005.03.31
> > (:if date 20051006-2006 :) 2005.10.06 through 2006.12.31
> > (:if date 20051006-200601 :) 2006.10.06 through 2006.01.31
> > (:if date 20051006-20060101 :) 2006.10.06 through 2006.01.01
> > (:if date 20051006-2005 :) 2005.10.06 through 2005.12.31
>
> Some truncated dates appear ambiguous. For example, I could interpret:
> (:if date 20051006-2006 :)
> as either 2005.10.06 to 2006.01.01 -or- 2005.10.06 to 2006.12.31
...or even 2005.10.06 through 2005.12.31, if one thinks of "-2006"
as meaning "strictly before 2006".
> And it somehow looks counter-intuitive that a shorter string like:
> (:if date 20051006-2006 :) specifies a *longer* period than (:if
> date 20051006-20060202 :)
Hey, you guys were the ones that wanted the ending date to include
the last day. :-) :-) In my original formulation, the ending date
would've always meant "strictly before", thus
(:if date 20051006-2006:) 2005.10.06 through 2005.12.31
(:if date 20051006-200601:) same thing
(:if date 20051006-20060101:) same thing
(:if date 20051006-200602:) 2005.10.06 through 2005.01.31
(:if date 20051006-20060201:) same thing
which matches your intuition of "longer strings are longer periods",
but tends to be counter-intuitive.
But even in English, the shorter string often corresponds to the
"longer period". For example, if I say that "movie XYZ will be
in theaters from now through 2006", people understand this to be
a longer period than if I had said "movie XYZ will be in theaters
from now through August 15, 2006".
> I know somebody can learn the rules, but why not avoid many of the
> rules by always requiring a complete date?
OTOH, one can always use complete dates and never have to learn the
rules. Truthfully, I don't expect the mixed-date formats to be all that
common; i.e., authors would typically limit themselves to
the forms where there's not really a lot of ambiguity, such as
(:if date 2005-2007:)
(:if date 200503-200602:)
(:if date 20050315-20060531:)
In fact, if I hadn't mentioned the mixed formats in my previous
post, I doubt many would've known they were possible. Ultimately,
it turns out to be a little easier for me to write code that
handles the mixed date formats than it is to try to restrict them,
and I tend to go with the simplest solutions first.
Pm
More information about the pmwiki-users
mailing list