mahiwaga

I'm not really all that mysterious

Jekyll timestamps and timezones

It just occurred to me that the way Jekyll handles timestamps and generates permalinks to posts is not ideal for me.

I do tend to post multiple times in a single day, so I need the granularity that the YAML frontmatter date field provides. But I also used to live in a different timezone (CST/CDT) when I first started blogging. (Now I live in PST/PDT.) I had explicitly stored the timestamp meta data in my posts and had intended to preserve them when converting to Markdown posts with YAML frontmatter, including timezone information.

Unfortunately, what happens to

  
date: 2015-07-23 01:00 -0500

  

is that when I parse it in my layouts, it gets turned into July 22, 2015 at 11:00 p.m. PDT (2015-07-22 11:00 -0700) and unexpectedly creates the permalink to /2015/07/22/… instead of to /2015/07/23/…

This is not a huge catastrophe since I’ve had to manually recode the permalinks in old entries anyway, but it is kind of a pain in the ass.

The other thing that is less than ideal is that since the timezone defaults to the localtime of your build environment, what I imagine will happen is that all the timestamps will change by an hour (and possibly by a day) when we switch from Daylight Saving Time to Standard Time (and vice-versa) after I regenerate my blog after cleaning.

Ideally, what I would like is that permalinks should always be generated based on the yyyy-mm-dd part alone without any reference to the hh:mm -zzzz part and that the hh:mm -zzzz part shouldn’t be converted to localtime when parsing, but should keep the explicitly stated timezone separate.

Now, there are a bunch of workarounds and all of them are huge kludges.

What I’ve settled down on are timestamps without any timezone date (yyyy-mm-dd hh:mm) and then creating a field tz with the TLA for the timezone (PST, PDT, CST, CDT, etc.)

  
date: 2015-07-23 01:00
tz: CDT

  

Perhaps it isn’t the most elegant solution, but I think it’ll get the job done.

initially published online on:
page regenerated on: