Skip to content

Commit

Permalink
Show positive number for BCE years
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed Jan 26, 2018
1 parent 2cf4d7e commit 7d6c1aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/z_dateformat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,11 @@ tag_to_value($y, {Y, _, _}, _, _Options) ->
Y1 = Y rem 100,
[ Y1 div 10 + $0, Y1 rem 10 + $0];

% Complete year: e.g. '2018', '-15038', or '333'
%% Complete year: e.g. '2018', '15038', or '333'.
%% BCE years are displayed as a positive number. Use $e to add the era to the
%% output.
tag_to_value($Y, {Y, _, _}, _, _Options) ->
integer_to_list(Y);
integer_to_list(abs(Y));

% Day of the year; i.e. '0' to '365'
tag_to_value($z, {Y,M,D}, _, _Options) ->
Expand Down
6 changes: 3 additions & 3 deletions test/z_dateformat_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@


dateformat_year_y_test() ->
?assertEqual(<<"-999">>, z_dateformat:format({{ -999,1,1},{0,0,0}}, "Y", [])),
?assertEqual(<<"999">>, z_dateformat:format({{ -999,1,1},{0,0,0}}, "Y", [])),
?assertEqual(<<"999">>, z_dateformat:format({{ 999,1,1},{0,0,0}}, "Y", [])),
?assertEqual(<<"-1000">>, z_dateformat:format({{ -1000,1,1},{0,0,0}}, "Y", [])),
?assertEqual(<<"1000">> , z_dateformat:format({{ -1000,1,1},{0,0,0}}, "Y", [])),
?assertEqual(<<"1000">>, z_dateformat:format({{ 1000,1,1},{0,0,0}}, "Y", [])),
?assertEqual(<<"-10000">>, z_dateformat:format({{-10000,1,1},{0,0,0}}, "Y", [])),
?assertEqual(<<"10000">>, z_dateformat:format({{-10000,1,1},{0,0,0}}, "Y", [])),
?assertEqual(<<"10000">>, z_dateformat:format({{ 10000,1,1},{0,0,0}}, "Y", [])),
ok.

Expand Down

0 comments on commit 7d6c1aa

Please sign in to comment.