summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Bolinder <hasse@erlang.org>2020-02-28 08:35:18 +0100
committerHans Bolinder <hasse@erlang.org>2020-02-28 08:35:18 +0100
commit31e3f542be9a1935aae823879fdfb7e8cb0942cd (patch)
treed3d82adbd2de4bc349c3c53ed082c6b0b0f55023
parentcdf09fdfc2acd8998849f4fb29458b7bf8a98b52 (diff)
parent6f5811d3b56034d90b305b7265450b6934b55832 (diff)
downloaderlang-31e3f542be9a1935aae823879fdfb7e8cb0942cd.tar.gz
Merge branch 'maint'
* maint: stdlib: Correct calendar:rfc3339_to_system_time()
-rw-r--r--lib/stdlib/src/calendar.erl8
-rw-r--r--lib/stdlib/test/calendar_SUITE.erl3
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/stdlib/src/calendar.erl b/lib/stdlib/src/calendar.erl
index 7f74e70a5a..2f95f54312 100644
--- a/lib/stdlib/src/calendar.erl
+++ b/lib/stdlib/src/calendar.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2019. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2020. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -370,7 +370,7 @@ rfc3339_to_system_time(DateTimeString, Options) ->
IsFractionChar = fun(C) -> C >= $0 andalso C =< $9 orelse C =:= $. end,
{FractionStr, UtcOffset} = lists:splitwith(IsFractionChar, TimeStr),
Time = datetime_to_system_time(DateTime),
- Secs = Time - offset_adjustment(Time, second, UtcOffset),
+ Secs = Time - offset_string_adjustment(Time, second, UtcOffset),
check(DateTimeString, Options, Secs),
ScaledEpoch = erlang:convert_time_unit(Secs, second, Unit),
ScaledEpoch + copy_sign(fraction(Unit, FractionStr), ScaledEpoch).
@@ -690,13 +690,13 @@ offset(OffsetOption, Secs0) when OffsetOption =:= "";
offset(OffsetOption, _Secs) ->
OffsetOption.
+offset_adjustment(Time, Unit, "") ->
+ local_offset(Time, Unit);
offset_adjustment(Time, Unit, OffsetString) when is_list(OffsetString) ->
offset_string_adjustment(Time, Unit, OffsetString);
offset_adjustment(_Time, Unit, Offset) when is_integer(Offset) ->
erlang:convert_time_unit(Offset, Unit, second).
-offset_string_adjustment(Time, Unit, "") ->
- local_offset(Time, Unit);
offset_string_adjustment(_Time, _Unit, "Z") ->
0;
offset_string_adjustment(_Time, _Unit, "z") ->
diff --git a/lib/stdlib/test/calendar_SUITE.erl b/lib/stdlib/test/calendar_SUITE.erl
index 224c0d5625..bea5a217db 100644
--- a/lib/stdlib/test/calendar_SUITE.erl
+++ b/lib/stdlib/test/calendar_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2019. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2020. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -223,6 +223,7 @@ rfc3339(Config) when is_list(Config) ->
{'EXIT', _} = (catch do_format_z(253402300799+1, [])),
{'EXIT', _} = (catch do_parse("9999-12-31T23:59:60Z", [])),
{'EXIT', _} = (catch do_format_z(253402300799*1000000000+999999999+1, Ns)),
+ {'EXIT', _} = (catch do_parse("2010-04-11T22:35:41", [])), % OTP-16514
253402300799 = do_parse("9999-12-31T23:59:59Z", []),
"0000-01-01T00:00:00Z" = test_parse("0000-01-01T00:00:00.0+00:00"),