Menu

#58 ISO8601 builtin for datetimes

2.3.21
closed-fixed
nobody
None
5
2014-10-16
2008-05-06
Peter Monks
No

Rather than having to hard code the ISO8601 format string throughout my templates, it would be nicer if Freemarker provided a builtin for outputting dates in ISO8601 format. It might be called "?iso" for example. (There's also ?iso since 2.3.19 or like.)

Discussion

  • Dániel Dékány

    Logged In: YES
    user_id=546667
    Originator: NO

    Throughout your templates? You should specify the date format only once, and either store it in a variable (so you can just write ${theDate?string(my.iso)}), or write a function that formats the date (like my.iso(theDate)). Or, just set the date_format setting to that format string, if the ISO 8601 format was the preferred (default) format. Does one of these working for you?

     
  • Peter Monks

    Peter Monks - 2008-05-26

    Logged In: YES
    user_id=7747
    Originator: YES

    While they're all equally valid approaches they don't really address the basic concern, which is that ISO8601 is a pervasive date/time format and as such it would be ideal if Freemarker had first class support for it, rather than requiring the template developer to do something to be able to use it (regardless of what that "something" is).

    I realise this is syntactic sugar, but that precedent has already been established elsewhere (eg. the ?c builtin for numbers).

     
  • Dániel Dékány

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1 @@
    -Rather than having to hard code the ISO8601 format string throughout my templates, it would be nicer if Freemarker provided a builtin for outputting dates in ISO8601 format.  It might be called "?iso" for example.
    +Rather than having to hard code the ISO8601 format string throughout my templates, it would be nicer if Freemarker provided a builtin for outputting dates in ISO8601 format.  It might be called "?iso" for example. (There's also `?iso` since 2.3.19 or like.)
    
    • status: open --> closed-fixed
    • Group: --> 2.3.21
     

Log in to post a comment.