gerwitz / sitewriter

Bringing IndieWeb to the JAM (Micropub for static sites)
http://sitewriter.net/
MIT License
22 stars 0 forks source link

UNIX time as a template/slug option #79

Closed paulrobertlloyd closed 6 years ago

paulrobertlloyd commented 6 years ago

So… I’ve been thinking a bit more about timezones, especially having just spent three weeks in Europe on UTC+2. It would seem that in the design of my site, I stumbled upon a few falsehoods about dates and times. Namely, while it’s probably correct to save a post with a local time and timezone, using this information for URLs is problematic, especially should I ever change the timezone for which I build my site (or this changes on the server, for some reason). 😩

Currently, my URL scheme for notes is /YYYY/MM/DD-HHMM. Were I to change my timezone from Europe/London to Europe/Berlin, /2018/01/01-1155 would now become /2018/01/02-0155. Whoops!

Anyway, this is a long way of asking… is it possible to have UNIX time as a template/slug option please? (This is the only other means I can think of for generating a predictable slug, not sure if there might be some other values I could use…?)

(Happy to see your return to this project BTW!)

gerwitz commented 6 years ago

Unix epoch time is a great choice for a predictable slug, though this depends on the context in which you want to predict it, of course! As I've been working on handling time, I've decided to define "now" early in receipt of a Micropub request, but that's quite arbitrary.

So you might as well use any format of UTC, or pseudorandomness.

And, of course, there's nothing about Unix time that makes it less susceptible to these problems, what if the server moves to another timezone?

Regardless, I'll add a unix_epoch variable.

gerwitz commented 6 years ago

Folding into #36