durusmail: quixote-users: is_running on BSD systems
is_running on BSD systems
2005-03-04
2005-03-04
2005-03-04
2005-03-04
2005-03-04
2005-03-05
2005-03-05
2005-03-05
2005-03-05
2005-03-05
2005-03-05
2005-03-05
local.format_date_time
2005-03-11
Re: R: [Quixote-users] is_running on BSD systems
2005-03-07
2005-03-07
2005-03-07
Re: R: [Quixote-users] is_running on BSD systems
2005-03-07
is_running on BSD systems
Michael Watkins
2005-03-05
> There is an interesting thread related to this in the zodb3-dev list:
> http://mail.zope.org/pipermail/zope3-dev/2005-February/013567.html
> I think we should change Dulcinea to use utcnow everywhere instead
> of now(), and just run all date formatting through a local.format_date
> as you
> suggest.

If we could always rely that the datetime objects were based on utc time
then that would suffice; then we can coerce datetime objects to be tz
aware if needed with a little more assurance.

Although I still have a hankering for being explicit and setting tzinfo...

from datetime import tzinfo, timedelta, datetime

ZERO = timedelta(0)

class utc(tzinfo):
    """UTC"""
    def __repr__(self):
        return "UTC"

    def utcoffset(self, dt):
        return ZERO

    def tzname(self, dt):
        return "UTC"

    def dst(self, dt):
        return ZERO

UTC = utc()

def utcnow():
    """return a tz aware datetime object set to zone UTC
    """
    return datetime.now(UTC)

reply