[Zope3-dev] tzinfo

Patrick K. O'Brien pobrien@orbtech.com
Mon, 18 Mar 2002 11:35:52 -0600


[Guido van Rossum]
> > tzisdst() returns 0 if DST is not in effect, or the DST offset if
> > DST is in effect. This sounds like a simple truth function, but it
> > returns an offset.  Should it be named dstoffset instead? Then we
> > would have toffset and dstoffset, which seems to be nicely
> > symmetrical.
>
> Except there's nothing in their functionality that requires symmetry.
> The UTC offset is required for comparison of time involving diffent
> timezones (which includes different DST offsets).  The dst info is
> never needed -- *this* is purely informational, in case the
> application is interested in the DST status (for which I still haven't
> seen a use case, BTW, but which Tim argues is needed from a
> "discoverability" perspective).  I'd almost call it dstinfo() except
> that would suggest a symmetry with tzinfo() which is also incorrect.
>
> I agree that the name "isdst()" for something returning an int whose
> nonzero value has (some) semantics is confusing.
>
> Maybe it should just be called dst()?

Ah! I was confused. I thought there was a symmetry and that comparisons
would make use of both UTC offset and DST offset. I didn't realize it was
purely informative. But I see now that I was still holding on to my desire
to keep these two concepts separate, where you want to join them together. I
can definitely see that requiring tzinfo to return a single utcoffset value,
which is the only value that has an impact on comparisons, greatly
simplifies the situation. So dst() would get my vote, plus a note on the
wiki that, like tzname(), dst() returns a value that is 100% informational.

> I'd also be happy to drop it, based on YAGNI (it's very easy to add in
> a later stage since it doesn't affect anything else).

If YAGNI and nobody can come up with a use case then I agree it should be
dropped.

> > tzinfo() returns the tzinfo object. This would be renamed to match
> > the hook, such as dtx().
>
> I like tzinfo() best.

Okay.

---
Patrick K. O'Brien
Orbtech