Login

Snippets by pgcd

Snippet List

Generate iCal VTIMEZONE block with DAYLIGHT and STANDARD components, based on pytz zoneinfo data

In the last few days I spent a lot of time trying to find a library or repository of some kind that could help me generate the required DAYLIGHT and STANDARD components of ical VTIMEZONE blocks. Since I couldn't find anything, I cobbled together this snippet to poke around in pytz timezone information and output the bare minimum I needed to make my ICS files compliant and useful (DST transitions for this year and the next). I promise it's (superficially) tested against "real" ICS files, but that's all. UPDATE: Thanks to @ariannedee for a much improved version (see comment for details)

  • pytz
  • timezones
  • ical
  • icalendar
  • ics
Read More

Parsing Tag decorator

A simple decorator to register a template.Node object as a tag, without the need to write the usual "`token.split_contents()` yatta yatta blatta blatta" function. The decorator should be called with the name of the tag, and an optional `required` named argument in case your tag requires a minimum number of arguments. Please note that all the arguments in the templatetag call will be passed to the node (except the templatetag name and the `for` and `as` keywords) in the order given. Suggestions etc are very welcome, of course =)

  • templatetag
Read More

pgcd has posted 2 snippets.