Skip to content
Browse files

to_isotime now assumes utc inputs, date formatter should be lowercase

  • Loading branch information...
1 parent 7559c35 commit b9f19b95e12c53b0287abab74f1dbaf84c0ef2f6 @mworrell mworrell committed
Showing with 5 additions and 6 deletions.
  1. +2 −3 src/z_convert.erl
  2. +1 −1 src/z_dateformat.erl
  3. +2 −2 test/z_convert_test.erl
View
5 src/z_convert.erl
@@ -276,13 +276,12 @@ to_time(L) when is_list(L) ->
[H,I,S|_] = lists:flatten([[to_integer(X) ||X <- string:tokens(L, ":.")], 0, 0]),
{H,I,S}.
-%% @doc Convert a datetime (in local time) to an ISO time string (in
-%% universal time).
+%% @doc Convert a datetime (in universal time) to an ISO time string.
-spec to_isotime(calendar:datetime()) -> string().
to_isotime(DateTime={D,_}) when D < {1970, 1, 1}->
to_list(z_dateformat:format(DateTime, "Y-m-d\\TH:i:s\\Z", en));
to_isotime(DateTime) ->
- to_list(z_dateformat:format(hd(calendar:local_time_to_universal_time_dst(DateTime)), "Y-m-d\\TH:i:s\\Z", en)).
+ to_list(z_dateformat:format(DateTime, "Y-m-d\\TH:i:s\\Z", en)).
%%
View
2 src/z_dateformat.erl
@@ -164,7 +164,7 @@ tag_to_value($s, _, {_,_,S}, _Options) ->
% Month, textual, 3 letters, lowercase; e.g. 'jan'
tag_to_value($b, {_,M,_}, _, Options) ->
- z_string:truncate(tr(monthname, M, Options), 3, <<>>);
+ z_string:to_lower(z_string:truncate(tr(monthname, M, Options), 3, <<>>));
% ISO 8601 date format - 2004-02-12T15:19:21+00:00
tag_to_value($c, Date, Time, Options) ->
View
4 test/z_convert_test.erl
@@ -46,6 +46,6 @@ convert_datetime_test() ->
ok.
datetime_to_iso_test() ->
- ?assertEqual("2010-09-02T10:11:56Z", z_convert:to_isotime(calendar:universal_time_to_local_time({{2010,9,2},{10,11,56}}))),
- ?assertEqual("2010-09-02T01:01:01Z", z_convert:to_isotime(calendar:universal_time_to_local_time({{2010,9,2},{1,1,1}}))),
+ ?assertEqual("2010-09-02T10:11:56Z", z_convert:to_isotime({{2010,9,2},{10,11,56}})),
+ ?assertEqual("2010-09-02T01:01:01Z", z_convert:to_isotime({{2010,9,2},{1,1,1}})),
ok.

0 comments on commit b9f19b9

Please sign in to comment.
Something went wrong with that request. Please try again.