aboutsummaryrefslogtreecommitdiff
path: root/lib/localtime.py
diff options
context:
space:
mode:
authorSkip Montanaro <[email protected]>2021-02-16 20:14:16 -0600
committerSkip Montanaro <[email protected]>2021-02-16 20:14:16 -0600
commitc2587c76f1b416cdbecb979e54941933246bf856 (patch)
treebb61ee9128075ce22af4eafa232f13c2e5a07896 /lib/localtime.py
parentd90761a005b24018ae237bf551515772a1de656f (diff)
downloadpython-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.tar.xz
python-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.zip
starting over
Diffstat (limited to 'lib/localtime.py')
-rw-r--r--lib/localtime.py70
1 files changed, 35 insertions, 35 deletions
diff --git a/lib/localtime.py b/lib/localtime.py
index 5ce6529..1b662e9 100644
--- a/lib/localtime.py
+++ b/lib/localtime.py
@@ -2,52 +2,52 @@
import posix
-epoch = 1970 # 1 jan 00:00:00, UCT
-day0 = 4 # day 0 was a thursday
+epoch = 1970 # 1 jan 00:00:00, UCT
+day0 = 4 # day 0 was a thursday
day_names = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')
-month_names = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun')
+month_names = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun')
month_names = month_names + ('Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
month_sizes = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
def isleap(year):
- return year % 4 = 0 and (year % 100 <> 0 or year % 400 = 0)
-
-def gmtime(secs): # decode time into UCT
- mins, secs = divmod(secs, 60)
- hours, mins = divmod(mins, 60)
- days, hours = divmod(hours, 24)
- wday = (day0 + days) % 7
- year = epoch
- lp = isleap(year)
- dpy = 365 + lp
- while days >= dpy:
- days = days - dpy
- year = year + 1
- lp = isleap(year)
- dpy = 365 + lp
- yday = days
- month = 0
- dpm = month_sizes[month] + (lp and month = 1)
- while days >= dpm:
- days = days - dpm
- month = month + 1
- dpm = month_sizes[month] + (lp and month = 1)
- return (year, month, days+1, hours, mins, secs, yday, wday)
+ return year % 4 = 0 and (year % 100 <> 0 or year % 400 = 0)
+
+def gmtime(secs): # decode time into UCT
+ mins, secs = divmod(secs, 60)
+ hours, mins = divmod(mins, 60)
+ days, hours = divmod(hours, 24)
+ wday = (day0 + days) % 7
+ year = epoch
+ lp = isleap(year)
+ dpy = 365 + lp
+ while days >= dpy:
+ days = days - dpy
+ year = year + 1
+ lp = isleap(year)
+ dpy = 365 + lp
+ yday = days
+ month = 0
+ dpm = month_sizes[month] + (lp and month = 1)
+ while days >= dpm:
+ days = days - dpm
+ month = month + 1
+ dpm = month_sizes[month] + (lp and month = 1)
+ return (year, month, days+1, hours, mins, secs, yday, wday)
def dd(x):
- s = `x`
- while len(s) < 2: s = '0' + s
- return s
+ s = `x`
+ while len(s) < 2: s = '0' + s
+ return s
def zd(x):
- s = `x`
- while len(s) < 2: s = ' ' + s
- return s
+ s = `x`
+ while len(s) < 2: s = ' ' + s
+ return s
def format(year, month, days, hours, mins, secs, yday, wday):
- s = day_names[wday] + ' ' + zd(days) + ' ' + month_names[month] + ' '
- s = s + dd(hours) + ':' + dd(mins) + ':' + dd(secs)
- return s
+ s = day_names[wday] + ' ' + zd(days) + ' ' + month_names[month] + ' '
+ s = s + dd(hours) + ':' + dd(mins) + ':' + dd(secs)
+ return s