PageRenderTime 33ms CodeModel.GetById 19ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/src/erlydtl/erlydtl_dateformat.erl

http://github.com/zotonic/zotonic
Erlang | 32 lines | 22 code | 9 blank | 1 comment | 0 complexity | 49ad8bc87c1d162697c668d5a4975237 MD5 | raw file
 1%%% Stub for old format calls to z_dateformat in z_stdlib.
 2
 3-module(erlydtl_dateformat).
 4
 5-export([
 6    format/2,
 7    format/3,
 8
 9    format_utc/2,
10    format_utc/3
11    ]).
12
13-include_lib("zotonic.hrl").
14
15format(Format, Context) ->
16    format(calendar:universal_time(), Format, Context).
17
18format(Date, Format, #context{} = Context) ->
19    z_dateformat:format(z_datetime:to_local(Date, Context), Format, opts(Date, z_context:tz(Context), Context)).
20
21format_utc(Format, Context) ->
22    format_utc(calendar:universal_time(), Format, Context).
23
24format_utc(Date, Format, #context{} = Context) ->
25    z_dateformat:format(Date, Format, opts(Date, "GMT", Context)).
26
27opts(Date, Tz, Context) ->
28	[
29        {utc, Date},
30        {tz, z_convert:to_list(Tz)},
31        {tr, {l10n_date, [Context]}}
32    ].