Discussion:
[FreeMarker-user] Survey: How ISO 8601 date formatting should work in FreeMarker 2.3.17
Daniel Dekany
2011-05-09 16:39:51 UTC
Permalink
The factors I'm not 100% sure about is:
- Using UTC VS local time zone
- Printing the time zone offset (including "Z") or not

The current plan is that if you have:

${exp?iso_utc}

Then, depending on the type of the expression value:
- If it's a date-only value, it prints something like
2010-05-09Z
- If it's a time-only value, it prints something like
18:15:16Z
or if the millisec part is not 0 then:
18:15:16.008Z
- If it's a date-time value then it's like:
2010-05-09T18:15:16Z
or
2010-05-09T18:15:16.008Z
- If it's not decided if which parts of the date is used (like if you drop
a java.util.Date into the data-model), then just like with non-ISO
formatting, the above will be an error, and you have to write something
like:
${exp?date?iso_utc}
${exp?time?iso_utc}
${exp?datetime?iso_utc}

So as you can see:
- The time zone is always UTC
- The offset is always shown ("Z", since it's UTC), even for
date-only values.

If you want to print with the local time zone (which is decided by the
"time_zone" setting of FreeMarker), then you have to write:

${exp?iso_local}

In this case instead of "Z" you will get an offset like ("+05:00").
The offset would be always shown here too.

If you don't want to show the offset then you had to write:

${exp?iso_utc_no}

or

${exp?iso_local_no}

where "no" stands for "No Offset". /-:

Opinions?
--
Best regards,
Daniel Dekany
Daniel Dekany
2011-05-09 19:33:23 UTC
Permalink
OK, there's one change already: Unless I'm blind, ISO 8601:2004
doesn't allow offset (time zone) after a pure date. So there won't be
2010-05-09Z, only 2010-05-09. Which strikes me as silly (because,
2010-05-09 in which time zone?)... but, what can I do.
Post by Daniel Dekany
- Using UTC VS local time zone
- Printing the time zone offset (including "Z") or not
${exp?iso_utc}
- If it's a date-only value, it prints something like
2010-05-09Z
- If it's a time-only value, it prints something like
18:15:16Z
18:15:16.008Z
2010-05-09T18:15:16Z
or
2010-05-09T18:15:16.008Z
- If it's not decided if which parts of the date is used (like if you drop
a java.util.Date into the data-model), then just like with non-ISO
formatting, the above will be an error, and you have to write something
${exp?date?iso_utc}
${exp?time?iso_utc}
${exp?datetime?iso_utc}
- The time zone is always UTC
- The offset is always shown ("Z", since it's UTC), even for
date-only values.
If you want to print with the local time zone (which is decided by the
${exp?iso_local}
In this case instead of "Z" you will get an offset like ("+05:00").
The offset would be always shown here too.
${exp?iso_utc_no}
or
${exp?iso_local_no}
Opinions?
--
Best regards,
Daniel Dekany
Daniel Dekany
2011-05-10 00:04:42 UTC
Permalink
Post by Daniel Dekany
OK, there's one change already: Unless I'm blind, ISO 8601:2004
doesn't allow offset (time zone) after a pure date. So there won't be
2010-05-09Z, only 2010-05-09. Which strikes me as silly (because,
2010-05-09 in which time zone?)... but, what can I do.
It is not silly. Think about it, can you offset 2 hours from a pure
date? A date is not linked to a timezone unless you attach a time to it.
A pure date, like 2010-05-09 represents a 24 hours long section of
time. The beginning and ending of that section depends on the time
offset, since days start and end at different points of physical time
in different time zones. Like 2010-05-09 in New York starts and ends 6
hours later than in Budapest.

Loading...