Am Mon, 13 Oct 2008 13:20:50 +0200
schrieb Michael Franzl <franzl at corporatematters.at>:
> When you declare a time in XML Format as metainfo key:
>
> custom_time: 2008-10-13T10:10:45+01:00
>
> or
>
> modified_at: 2008-10-13T10:10:45+01:00
>
> and use it somewhere else like this
>
> <%= "#{node[''custom_time'']}" %>
> <%= "#{node[''modified_at'']}" %>
>
> then the output of both statements is
>
> Mon Oct 13 11:10:45 +0200 2008
>
> Is it possible to change the time format to something else? At least
> to keep it as-is, i.e. "2008-10-13T10:10:45+01:00"?
Just use Ruby''s Time#strftime method to format the time, for example:
<%=
node[''custom_time''].strftime(''%Y%m%d'')
Note that this only works if the time in the meta information is a
formatted as a valid YAML time (see
http://webgen.rubyforge.org/documentation/reference_metainfo.html#modified_at),
Otherwise you would just get a string and not a Time object! Also note
that if you leave out the hour and time, you just get a Date object!
-- Thomas