~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-01-04 21:39:03 UTC
  • mfrom: (2221.1.1 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070104213903-ddc3293ca385e7a9
(James Henstridge) Don't rely on time.timezone and time.altzone, since they are not always updated properly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
from bzrlib.lazy_import import lazy_import
27
27
lazy_import(globals(), """
 
28
from datetime import datetime
28
29
import errno
29
30
from ntpath import (abspath as _nt_abspath,
30
31
                    join as _nt_join,
554
555
 
555
556
def local_time_offset(t=None):
556
557
    """Return offset of local zone from GMT, either at present or at time t."""
557
 
    # python2.3 localtime() can't take None
558
558
    if t is None:
559
559
        t = time.time()
560
 
        
561
 
    if time.localtime(t).tm_isdst and time.daylight:
562
 
        return -time.altzone
563
 
    else:
564
 
        return -time.timezone
 
560
    offset = datetime.fromtimestamp(t) - datetime.utcfromtimestamp(t)
 
561
    return offset.days * 86400 + offset.seconds
565
562
 
566
563
    
567
564
def format_date(t, offset=0, timezone='original', date_fmt=None,