A couple of weeks ago, Siobhan pointed out to me the difficulties in talking about times for IRC meetups on the various P2 P2 or O2 is the term people use to refer to the Make WordPress blog. It can be found at https://make.wordpress.org/. blogs. She suggested a shortcode A shortcode is a placeholder used within a WordPress post, page, or widget to insert a form or function generated by a plugin in a specific location on your site. 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 JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. 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