Question

Is there an easy way to have template-toolkit accept date/times in ISO 8601 format as input?

http://en.wikipedia.org/wiki/ISO_8601

Specifically I'm looking for the combined date/time format assuming UTC time:

yyyy-mm-ddThh:mm:ssZ

and then have TT adjust timezone & formatting based on locale.

Was it helpful?

Solution

Sure, you should use DateTime module, and DateTime::Format::Strptime to parse and format (transform from DateTime to string and viceversa.

OTHER TIPS

This appears to work, but it's a bit kludgy:

<% USE date %>
...
<% date.format(mydatetime.substr(0,10) _ ' ' _ mydatetime.substr(11,8), '%c', 'en_US') %>

Open to other suggestions. Assumes en_US as locale.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top