Jekyll timezones

Photo I took of Singapore in 2012

UPDATE: This date issue seems to be resolved as of Jekyll 1.5.1. As such, this post should be considered hysterical historical.

With almost four thousand posts written in different countries over the last nine years, I often feel as though my use case really tests the limits of Jekyll. To be fair, it has performed admirably.

One area where I've continued to struggle is with timezones. According to the Jekyll documentation, you declare timezones within the date YAML front matter for a post, such as this:

date: 2014-01-10 12:06:21 +1100

For posts written in Singapore and KL, I set the date with "+0800", with Adelaide as "+0930" and Sydney as "+1000" or "+1100" depending on daylight savings. Suddently, my times are even more accurate than they were when I exported them from WordPress last year, a nice feature!

There's just one catch. When Jekyll generates my site, these dates are converted to UTC. Under most circumstances this is fine; it's a more universally understood representation of the same time. Where this becomes a problem is human readable dates.

Say for example I posted this entry at 01:00 +1100. This means I'd expect my site to say Friday 10 January. Because it gets converted to UTC internally however, my blog says it was posted Thursday 09 January.

A temporary workaround

It's not very elegant, but for now I define a separate timezone variable in my post YAML front matter:

layout: post
title: "Jekyll timezones"
date: "2014-01-10T12:06:21+1100
tz: "+1100"

Now, whenever I need to show the date in my Liquid markup, I substitute the default Jekyll date functions with these:

{{ | date: "%Y-%m-%dT%H:%M:%S" }}{{ }}
{{ | date: "%A %d %B %Y" }}

Which generates these: