posativ / acrylamid

(unmaintained) static blog generator in python with incremental rendering ⛺
http://posativ.org/acrylamid/
Other
277 stars 40 forks source link

RSS and TZ #181

Closed vbeffara closed 11 years ago

vbeffara commented 11 years ago

Hi again,

I was having trouble generating an RSS feed, something to do with subtracting datestamps with and without timezone info: in feeds.py, epoch always has one but for dt it seems to dpend on what is specified as the 'date' field.

The attached patch attaches TZ info to epoch only if there is one in td.

What do you think of it?

posativ commented 11 years ago

That's probably a bug in the post reader, because all datetime objects should be timezone aware. Do you use reST, MD or pandoc format? In case of YAML, with pyyaml installed?

The RSS feeds requires timezone aware dates because of daylight saving times the actual output string differs every half year.

vbeffara commented 11 years ago

That's using markdown, METASTYLE='native', with a timestamp format '%d.%m.%Y'.

Actually, something that might be worth changing: right now DATE_FORMAT is used both for creating new posts and for parsing previous ones. It would make sense to separate the two, and use something like python-dateutil for "agnostic" parsing instead of strptime (dateutil.parser.parse is extremely versatile, including options to set defaults for things like typically the timezone, for which using the local one when it is not specified is quite natural).

Reading the code, all my problems would probably be fixed by having TZINFO in my config file; a quickie would be to replace None with UTC in readers.py:261 ?

vbeffara commented 11 years ago

... BTW as I understand it, right now it is not possible to specify TZ in the date: field of a post? Using self.tzinfo feels more like a backup.

posativ commented 11 years ago

It would make sense to separate the two, and use something like python-dateutil for "agnostic" parsing instead of strptime

python-dateutil is a dependency I try to avoid, because most features are not really needed here.

Your mentioned line readers.py:261 is actually quite senseless, because tzinfo is always set during the initialize step in commands.py:90. I still don't know where tz-unware datetime objects gets into the parsing/compilation flow.

posativ commented 11 years ago

... BTW as I understand it, right now it is not possible to specify TZ in the date: field of a post? Using self.tzinfo feels more like a backup.

Yes, a tzinfo field would be nice if you're traveling around the world while writing. The current fallback assumes you're always in the same timezone.

vbeffara commented 11 years ago

OK, you're right about readers.py. But certainly the dt caught by the lambda in feeds.py:113 does not have a timezone info in my setup. And I'm still not familiar enough with all the callbacks and execution flow to trace where this comes from - as indeed IIRC it does have one out of readers.py ... I will investigate a bit more.

posativ commented 11 years ago

Can you post a traceback by any chance?

vbeffara commented 11 years ago

Mmmmkay, found it. feeds.py:69 produces a tz-less value for updated on my system. This works: https://gist.github.com/anonymous/6268644

posativ commented 11 years ago

Ah, right! That has been fixed in the master branch already... I think it is time to release 0.8 :S. Will you submit this patch or should I commit myself?

vbeffara commented 11 years ago

Just a sec, I will do a pull request.