ISO 8601 formatting in 2.3.17: will it be OK this way?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ISO 8601 formatting in 2.3.17: will it be OK this way?

Daniel Dekany
Since 2.3.17 is due within 22 hours or so, this is the last chance to
tell your requirements regarding this.

See the ?iso... built-ins below (this is the test case BTW).

Some notes:
- The meaning of things after iso_... are:
  - utc:   use UTC "time zone"
  - local: use the value of the time_zone setting of FreeMarker
  - ms: millisecond accuracy (the default is second accuracy).
        This will show "fraction seconds", not really milliseconds.
        So 00:00:00 plus 200 ms looks like "00:00:00.2",
        00:00:00 plus 230 ms looks like "00:00:00.23",
        00:00:00 plus 0 ms looks like "00:00:00", etc.
  - m:  minute accuracy (the default is second accuracy)
  - h:  hour accuracy (the default is second accuracy)
  - nz: don't show time zone (UTC offset, actually). Note that
        date-only formats never show the time zone, since ISO
        8601:2004 doesn't mention that it's allowed (right?).
- If `d` below was a javax.sql.Date or javax.sql.Time, the ?date or
  ?time part would be redundant, as FM will detect what it is.
- `javaUTC` and `javaGMT02` are java.util.TimeZone objects dropped into
  the data-model, not strings.


<#setting locale="us">
<#assign d = "2010-05-15 22:38:05:23 +0200"?datetime("yyyy-MM-dd HH:mm:ss:S Z")>
<#setting time_zone="GMT+02">
${d?iso_utc} = 2010-05-15T20:38:05Z
${d?iso_utc_ms} = 2010-05-15T20:38:05.023Z
${d?iso_utc_m} = 2010-05-15T20:38Z
${d?iso_utc_h} = 2010-05-15T20Z
${d?iso_utc_nz} = 2010-05-15T20:38:05
${d?iso_utc_ms_nz} = 2010-05-15T20:38:05.023
${d?iso_utc_m_nz} = 2010-05-15T20:38
${d?iso_utc_h_nz} = 2010-05-15T20
${d?iso_local} = 2010-05-15T22:38:05+02
${d?iso_local_ms} = 2010-05-15T22:38:05.023+02
${d?iso_local_m} = 2010-05-15T22:38+02
${d?iso_local_h} = 2010-05-15T22+02
${d?iso_local_nz} = 2010-05-15T22:38:05
${d?iso_local_ms_nz} = 2010-05-15T22:38:05.023
${d?iso_local_m_nz} = 2010-05-15T22:38
${d?iso_local_h_nz} = 2010-05-15T22

${d?date?iso_utc} = 2010-05-15
${d?date?iso_utc_ms} = 2010-05-15
${d?date?iso_utc_m} = 2010-05-15
${d?date?iso_utc_h} = 2010-05-15
${d?date?iso_utc_nz} = 2010-05-15
${d?date?iso_utc_ms_nz} = 2010-05-15
${d?date?iso_utc_m_nz} = 2010-05-15
${d?date?iso_utc_h_nz} = 2010-05-15
${d?date?iso_local} = 2010-05-15
${d?date?iso_local_ms} = 2010-05-15
${d?date?iso_local_m} = 2010-05-15
${d?date?iso_local_h} = 2010-05-15
${d?date?iso_local_nz} = 2010-05-15
${d?date?iso_local_ms_nz} = 2010-05-15
${d?date?iso_local_m_nz} = 2010-05-15
${d?date?iso_local_h_nz} = 2010-05-15

${d?time?iso_utc} = 20:38:05Z
${d?time?iso_utc_ms} = 20:38:05.023Z
${d?time?iso_utc_m} = 20:38Z
${d?time?iso_utc_h} = 20Z
${d?time?iso_utc_nz} = 20:38:05
${d?time?iso_utc_ms_nz} = 20:38:05.023
${d?time?iso_utc_m_nz} = 20:38
${d?time?iso_utc_h_nz} = 20
${d?time?iso_local} = 22:38:05+02
${d?time?iso_local_ms} = 22:38:05.023+02
${d?time?iso_local_m} = 22:38+02
${d?time?iso_local_h} = 22+02
${d?time?iso_local_nz} = 22:38:05
${d?time?iso_local_ms_nz} = 22:38:05.023
${d?time?iso_local_m_nz} = 22:38
${d?time?iso_local_h_nz} = 22

<#assign dStrange = "600-01-01 23:59:59:123 +0000"?datetime("yyyy-MM-dd HH:mm:ss:S Z")>
${dStrange?iso_utc_ms} = 0600-01-01T23:59:59.123Z

<#setting time_zone="GMT+03"> <#-- will have no effect -->
${d?iso("UTC")} = 2010-05-15T20:38:05Z
${d?iso_ms("UTC")} = 2010-05-15T20:38:05.023Z
${d?iso_m("UTC")} = 2010-05-15T20:38Z
${d?iso_h("UTC")} = 2010-05-15T20Z
${d?iso_nz("UTC")} = 2010-05-15T20:38:05
${d?iso_ms_nz("UTC")} = 2010-05-15T20:38:05.023
${d?iso_m_nz("UTC")} = 2010-05-15T20:38
${d?iso_h_nz("UTC")} = 2010-05-15T20
${d?iso("GMT+02")} = 2010-05-15T22:38:05+02
${d?iso_ms("GMT+02")} = 2010-05-15T22:38:05.023+02
${d?iso_m("GMT+02")} = 2010-05-15T22:38+02
${d?iso_h("GMT+02")} = 2010-05-15T22+02
${d?iso_nz("GMT+02")} = 2010-05-15T22:38:05
${d?iso_ms_nz("GMT+02")} = 2010-05-15T22:38:05.023
${d?iso_m_nz("GMT+02")} = 2010-05-15T22:38
${d?iso_h_nz("GMT+02")} = 2010-05-15T22

${d?date?iso("UTC")} = 2010-05-15
${d?date?iso_ms("UTC")} = 2010-05-15
${d?date?iso_m("UTC")} = 2010-05-15
${d?date?iso_h("UTC")} = 2010-05-15
${d?date?iso_nz("UTC")} = 2010-05-15
${d?date?iso_ms_nz("UTC")} = 2010-05-15
${d?date?iso_m_nz("UTC")} = 2010-05-15
${d?date?iso_h_nz("UTC")} = 2010-05-15
${d?date?iso("GMT+02")} = 2010-05-15
${d?date?iso_ms("GMT+02")} = 2010-05-15
${d?date?iso_m("GMT+02")} = 2010-05-15
${d?date?iso_h("GMT+02")} = 2010-05-15
${d?date?iso_nz("GMT+02")} = 2010-05-15
${d?date?iso_ms_nz("GMT+02")} = 2010-05-15
${d?date?iso_m_nz("GMT+02")} = 2010-05-15
${d?date?iso_h_nz("GMT+02")} = 2010-05-15

${d?time?iso("UTC")} = 20:38:05Z
${d?time?iso_ms("UTC")} = 20:38:05.023Z
${d?time?iso_m("UTC")} = 20:38Z
${d?time?iso_h("UTC")} = 20Z
${d?time?iso_nz("UTC")} = 20:38:05
${d?time?iso_ms_nz("UTC")} = 20:38:05.023
${d?time?iso_m_nz("UTC")} = 20:38
${d?time?iso_h_nz("UTC")} = 20
${d?time?iso("GMT+02")} = 22:38:05+02
${d?time?iso_ms("GMT+02")} = 22:38:05.023+02
${d?time?iso_m("GMT+02")} = 22:38+02
${d?time?iso_h("GMT+02")} = 22+02
${d?time?iso_nz("GMT+02")} = 22:38:05
${d?time?iso_ms_nz("GMT+02")} = 22:38:05.023
${d?time?iso_m_nz("GMT+02")} = 22:38
${d?time?iso_h_nz("GMT+02")} = 22

${d?iso(javaUTC)} = 2010-05-15T20:38:05Z
${d?iso(javaGMT02)} = 2010-05-15T22:38:05+02

<#attempt>
  ${d?iso("no such zone")}
<#recover>
  unrecognized time zone name
</#attempt>

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: ISO 8601 formatting in 2.3.17: will it be OK this way?

Denis Bredelet


> ${d?iso(javaUTC)} = 2010-05-15T20:38:05Z
> ${d?iso(javaGMT02)} = 2010-05-15T22:38:05+02

Are these two variables added to the root or are they standard?

-- Denis.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: ISO 8601 formatting in 2.3.17: will it be OK this way?

Daniel Dekany
Monday, May 16, 2011, 9:35:24 AM, Denis Bredelet wrote:

>
>
>> ${d?iso(javaUTC)} = 2010-05-15T20:38:05Z
>> ${d?iso(javaGMT02)} = 2010-05-15T22:38:05+02
>
> Are these two variables added to the root or are they standard?

They are just added to the test case data-model, like:

     dataModel.put("javaGMT02", TimeZone.getTimeZone("GMT+02"));
     dataModel.put("javaUTC", TimeZone.getTimeZone("UTC"));

(Standard variables are referred with a preceding dot in FreeMarker,
like ${.version}.)

> -- Denis.

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel