Skip to content

Commit a2191e4

Browse files
committed
Refactor format rfc822 datetime.
1 parent f49dd13 commit a2191e4

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

code/libs/session.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,10 @@ def get_site_cookie(environ, site):
2121
def format_rfc822_date(dt, localtime=True, cookie_format=False):
2222
if localtime:
2323
dt = dt - timedelta(hours=8)
24-
fmt = "%s, %02d %s %04d %02d:%02d:%02d GMT"
24+
fmt = '%a, %d %b %Y %H:%M:%S GMT'
2525
if cookie_format:
26-
fmt = "%s, %02d-%s-%04d %02d:%02d:%02d GMT"
27-
28-
# dt.strftime('%a, %d-%b-%Y %H:%M:%S GMT')
29-
return fmt % (["Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
30-
"Sun"][dt.weekday()],
31-
dt.day,
32-
["Jan", "Feb", "Mar", "Apr", "May", "Jun",
33-
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][dt.month - 1],
34-
dt.year, dt.hour, dt.minute, dt.second)
26+
fmt = '%a, %d-%b-%Y %H:%M:%S GMT'
27+
return dt.strftime(fmt)
3528

3629

3730
def format_cookie_date(dt, localtime=True):

0 commit comments

Comments
 (0)