641
642
offset = datetime.fromtimestamp(t) - datetime.utcfromtimestamp(t)
642
643
return offset.days * 86400 + offset.seconds
645
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
645
647
def format_date(t, offset=0, timezone='original', date_fmt=None,
646
648
show_offset=True):
672
674
offset_str = ' %+03d%02d' % (offset / 3600, (offset / 60) % 60)
677
# day of week depends on locale, so we do this ourself
678
date_fmt = date_fmt.replace('%a', weekdays[tt[6]])
675
679
return (time.strftime(date_fmt, tt) + offset_str)
1175
1179
pending.extend(d for d in reversed(dirblock) if d[2] == _directory)
1182
_real_walkdirs_utf8 = None
1178
1184
def _walkdirs_utf8(top, prefix=""):
1179
1185
"""Yield data about all the directories in a tree.
1189
1195
path-from-top might be unicode or utf8, but it is the correct path to
1190
1196
pass to os functions to affect the file in question. (such as os.lstat)
1192
fs_encoding = _fs_enc.upper()
1193
if (sys.platform == 'win32' or
1194
fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968')): # ascii
1195
return _walkdirs_unicode_to_utf8(top, prefix=prefix)
1197
return _walkdirs_fs_utf8(top, prefix=prefix)
1198
global _real_walkdirs_utf8
1199
if _real_walkdirs_utf8 is None:
1200
fs_encoding = _fs_enc.upper()
1201
if win32utils.winver == 'Windows NT':
1202
# Win98 doesn't have unicode apis like FindFirstFileW
1203
# TODO: We possibly could support Win98 by falling back to the
1204
# original FindFirstFile, and using TCHAR instead of WCHAR,
1205
# but that gets a bit tricky, and requires custom compiling
1208
from bzrlib._walkdirs_win32 import _walkdirs_utf8_win32_find_file
1210
_real_walkdirs_utf8 = _walkdirs_unicode_to_utf8
1212
_real_walkdirs_utf8 = _walkdirs_utf8_win32_find_file
1213
elif fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968'):
1214
# ANSI_X3.4-1968 is a form of ASCII
1215
_real_walkdirs_utf8 = _walkdirs_unicode_to_utf8
1217
_real_walkdirs_utf8 = _walkdirs_fs_utf8
1218
return _real_walkdirs_utf8(top, prefix=prefix)
1200
1221
def _walkdirs_fs_utf8(top, prefix=""):