~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Alexander Belchenko
  • Date: 2007-01-04 23:36:44 UTC
  • mfrom: (2224 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2225.
  • Revision ID: bialix@ukr.net-20070104233644-7znkxoj9b0y7ev28
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.lazy_import import lazy_import
27
27
lazy_import(globals(), """
28
28
import codecs
 
29
from datetime import datetime
29
30
import errno
30
31
from ntpath import (abspath as _nt_abspath,
31
32
                    join as _nt_join,
311
312
rename = os.rename
312
313
dirname = os.path.dirname
313
314
basename = os.path.basename
 
315
split = os.path.split
 
316
splitext = os.path.splitext
314
317
# These were already imported into local scope
315
318
# mkdtemp = tempfile.mkdtemp
316
319
# rmtree = shutil.rmtree
564
567
 
565
568
def local_time_offset(t=None):
566
569
    """Return offset of local zone from GMT, either at present or at time t."""
567
 
    # python2.3 localtime() can't take None
568
570
    if t is None:
569
571
        t = time.time()
570
 
        
571
 
    if time.localtime(t).tm_isdst and time.daylight:
572
 
        return -time.altzone
573
 
    else:
574
 
        return -time.timezone
 
572
    offset = datetime.fromtimestamp(t) - datetime.utcfromtimestamp(t)
 
573
    return offset.days * 86400 + offset.seconds
575
574
 
576
575
    
577
576
def format_date(t, offset=0, timezone='original', date_fmt=None,