jinja2-time icon indicating copy to clipboard operation
jinja2-time copied to clipboard

Impossible to format ISO-8601

Open slisznia opened this issue 8 years ago • 3 comments
trafficstars

When using your time filter, it's currently not possible to get the behavior of isoformat() method. Notice that strftime does not support getting ISO 8601; any attempt at reconstructing it fails, meaning the timezone offset is missing the colon in %z, example:

Correct: 2017-01-15T11:11:43+06:00 Incorrect: 2017-01-15T11:11:43+0600

Would you consider adding a special marker that would be a pass-through to calling isoformat() of arrow?

Alternatively, please provide access to Arrow's Tokens where 'ZZ' is used precisely for above (-07:00, -06:00 ... +06:00, +07:00)

slisznia avatar Jan 15 '17 17:01 slisznia

Hi @slisznia! 👋

I'm happy to extend the functionality of jinja2-time, as long we we don't break the current API as it is used for https://github.com/audreyr/cookiecutter.

Any ideas how to expose isotime and a like in a good way?

hackebrot avatar Jan 15 '17 19:01 hackebrot

OK, let's think about it. Arrow provides several formatting methods:

  • strftime (the one you currently are calling)
  • format (the one that supports ISO and other formats)
  • humanize (this one permits things like "2 hours ago", etc)

So, the question is how can your package support invoking alternative formatters?. By default -- for backwards compatibility -- you want to call strftime, but allow developers to pick another formatter like 'format' or 'humanize' of Arrow. How about this: the 'now' tag selects strftime, then add 'now-humanize' and 'now-format' to pick the other two?

slisznia avatar Jan 16 '17 04:01 slisznia

Per my PR #5, I think that arrow should be dropped entirely, though providing access to isoformat() or an alternative formatter doesn't seem like a bad idea.

pganssle avatar Jan 02 '18 18:01 pganssle