mirror of https://github.com/tildeclub/ttbp.git
timezone info
This commit is contained in:
parent
3a8630f2a7
commit
3e16943f32
|
@ -238,6 +238,7 @@ instance of this yourself)
|
||||||
* [six](https://pypi.python.org/pypi/six)
|
* [six](https://pypi.python.org/pypi/six)
|
||||||
* [colorama](https://pypi.python.org/pypi/colorama)
|
* [colorama](https://pypi.python.org/pypi/colorama)
|
||||||
* [feedgen](https://pypi.python.org/pypi/feedgen)
|
* [feedgen](https://pypi.python.org/pypi/feedgen)
|
||||||
|
* [dateutil](https://pypi.python.org/pypi/python-dateutil)
|
||||||
|
|
||||||
### contributing
|
### contributing
|
||||||
|
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -22,6 +22,7 @@ setup(
|
||||||
'colorama',
|
'colorama',
|
||||||
'six',
|
'six',
|
||||||
'feedgen',
|
'feedgen',
|
||||||
|
'python-dateutil',
|
||||||
],
|
],
|
||||||
include_package_data = True,
|
include_package_data = True,
|
||||||
entry_points = {
|
entry_points = {
|
||||||
|
|
11
ttbp/atom.py
11
ttbp/atom.py
|
@ -38,7 +38,7 @@ import os
|
||||||
import mistune
|
import mistune
|
||||||
import datetime
|
import datetime
|
||||||
import stat
|
import stat
|
||||||
import time
|
from dateutil import tz
|
||||||
|
|
||||||
def publish_atom(entry_filenames, settings):
|
def publish_atom(entry_filenames, settings):
|
||||||
fg = FeedGenerator()
|
fg = FeedGenerator()
|
||||||
|
@ -50,6 +50,7 @@ def publish_atom(entry_filenames, settings):
|
||||||
fg.link(href=url+'/', rel='alternate')
|
fg.link(href=url+'/', rel='alternate')
|
||||||
fg.link(href=url+'/atom.xml', rel='self')
|
fg.link(href=url+'/atom.xml', rel='self')
|
||||||
fg.language('en') # TODO: feels language should be configurable
|
fg.language('en') # TODO: feels language should be configurable
|
||||||
|
fg.updated(datetime.datetime.now(tz.tzlocal()))
|
||||||
|
|
||||||
for filename in sorted(entry_filenames):
|
for filename in sorted(entry_filenames):
|
||||||
date = util.parse_date(filename)
|
date = util.parse_date(filename)
|
||||||
|
@ -68,11 +69,13 @@ def publish_atom(entry_filenames, settings):
|
||||||
fe.author(name=config.USER)
|
fe.author(name=config.USER)
|
||||||
fe.content(html, type="html")
|
fe.content(html, type="html")
|
||||||
try: # crashing because of an invalid date would be sad
|
try: # crashing because of an invalid date would be sad
|
||||||
fe.published("-".join(date)+"T00:00:00Z")
|
year, month, day = [int(x) for x in date]
|
||||||
|
fe.published(datetime.datetime(year, month, day,
|
||||||
|
tzinfo=tz.tzlocal()))
|
||||||
stats = os.stat(path)
|
stats = os.stat(path)
|
||||||
updated = datetime.datetime.fromtimestamp(stats[stat.ST_MTIME],
|
updated = datetime.datetime.fromtimestamp(stats[stat.ST_MTIME],
|
||||||
datetime.timezone.utc)
|
tz.tzlocal())
|
||||||
fe.updated(updated.strftime('%Y-%m-%dT%H:%M:%SZ'))
|
fe.updated(updated)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
outfile = os.path.join(config.WWW, 'atom.xml')
|
outfile = os.path.join(config.WWW, 'atom.xml')
|
||||||
|
|
Loading…
Reference in New Issue