Time Shortcode for Make P2s

A couple of weeks ago, Siobhan pointed out to me the difficulties in talking about times for IRC meetups on the various P2 blogs. She suggested a shortcode to make it easier to specify times.

So I wrote a first draft of a shortcode to make this a bit easier. It’s not perfect, but I figured to go ahead and tell people now, so that you all could go ahead and start banging on it and telling me what the problems are.

Usage: [time] some-time-format-here [/time]

By “some-time-format-here”, I’m being a bit generous. You can use pretty much any time format you can think of and it will attempt to figure it out. With extra emphasis on “attempt”.

Stuff like this all works:

  • March 30, 2013 1pm UTC
  • April 4th at 1pm
  • April 4th around 1pm
  • April 4th 2012 1pm
  • next monday 1pm CDT
  • 1pm UTC

Now, a few important points:

  • If you don’t specify a timezone, you’ll probably get UTC. This is just for now, until I work out a better way.
  • If it can’t figure it out, you’ll notice no change in your text. Hopefully.
  • If it gets really confused, it’ll probably say January 1st, 1970. 🙂
  • “Absolute” times are more likely to work than “relative” ones. Give a date, and year, and time, and timezone, and you’ll probably be good.
  • Timezones matter in terms of daylight savings. GMT is not the same as BST (British Summer Time).

So, what’s the point? Well, if it can figure out what time you meant, then it’ll encode that and a bit of Javascript will then localize that time to the viewer of the make P2 in question on load, assuming their browser knows what timezone they’re in.

So when I post “April 3rd, 2013 6:30pm CDT” (my current time) in the time shortcode, it’ll show this instead: April 3rd, 2013 6:30pm CDT. What you see there depends on where you live.

Hopefully this will make it somewhat easier to schedule IRC meetups and such. Let me know when (not if) you break it. Happy to iterate.

#make, #plugin