Browse Source

Fix locale sensitive test

Takeru Ohta 7 years ago
parent
commit
eef186b99d
1 changed files with 8 additions and 1 deletions
  1. 8 1
      test/jsone_encode_tests.erl

+ 8 - 1
test/jsone_encode_tests.erl

@@ -142,7 +142,14 @@ encode_test_() ->
       end},
      {"datetime: iso8601: local",
       fun () ->
-              ?assertMatch({ok, <<"\"2015-06-25T14:57:25",_:6/binary,"\"">>}, jsone_encode:encode({{2015,6,25},{14,57,25}}, [{datetime_format, {iso8601, local}}]))
+              {ok, Json} = jsone_encode:encode({{2015,6,25},{14,57,25}}, [{datetime_format, {iso8601, local}}]),
+
+              UTC = {{1970, 1, 2}, {0,0,0}},
+              Local = calendar:universal_time_to_local_time({{1970, 1, 2}, {0,0,0}}),
+              case UTC =:= Local of
+                  false -> ?assertMatch(<<"\"2015-06-25T14:57:25",_:6/binary,"\"">>, Json);
+                  true  -> ?assertMatch(<<"\"2015-06-25T14:57:25Z\"">>, Json)
+              end
       end},
      {"datetime: iso8601: timezone",
       fun () ->