mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Fix timezone bug for ATOM generation
This commit is contained in:
parent
66ca61dfbb
commit
32a6ecbcc5
4 changed files with 16 additions and 9 deletions
|
|
@ -4,6 +4,7 @@ import os
|
|||
import shutil
|
||||
import time
|
||||
import calendar
|
||||
import pytz
|
||||
from datetime import datetime
|
||||
from codecs import open as _open
|
||||
from itertools import groupby
|
||||
|
|
@ -225,9 +226,12 @@ def files_changed(path, extensions):
|
|||
return True
|
||||
return False
|
||||
|
||||
def local_to_utc(t):
|
||||
"Convert article time to UTC time for ATOM feeds"
|
||||
secs = time.mktime(t)
|
||||
gmtime = list(time.gmtime(secs))
|
||||
gmtime[8] = 1
|
||||
return datetime.fromtimestamp(time.mktime(gmtime))
|
||||
def set_date_tzinfo(d, tz_name=None):
|
||||
""" Date without tzinfo shoudbe utc.
|
||||
This function set the right tz to date that aren't utc and don't have tzinfo
|
||||
"""
|
||||
if tz_name is not None:
|
||||
tz = pytz.timezone(tz_name)
|
||||
return tz.localize(d)
|
||||
else:
|
||||
return d
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue