Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
5871-Allow-the-timezone-part-of-the-string-to-c...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5871-Allow-the-timezone-part-of-the-string-to-contain-onl.patch of Package erlang
From c86176bfad3b82d9d24c51735dbd24afd6b2512f Mon Sep 17 00:00:00 2001 From: Dieter Schoen <dieter@schoen.or.at> Date: Sat, 25 Jun 2022 11:29:41 +0200 Subject: [PATCH] Allow the timezone part of the string to contain only an hour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RFC3339 declares the minutes part of the timezone diff as optional, which is now enabled with this commit. E.g.: 2022-06-25 11:04:00+02 is now possible. Co-authored-by: Björn Gustavsson <bgustavsson@gmail.com> --- lib/stdlib/doc/src/calendar.xml | 3 ++- lib/stdlib/src/calendar.erl | 9 +++++++-- lib/stdlib/test/calendar_SUITE.erl | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/stdlib/doc/src/calendar.xml b/lib/stdlib/doc/src/calendar.xml index fd42939a81..b6fc42de78 100644 --- a/lib/stdlib/doc/src/calendar.xml +++ b/lib/stdlib/doc/src/calendar.xml @@ -331,7 +331,8 @@ <desc> <p>Converts an RFC 3339 timestamp into system time. The data format of RFC 3339 timestamps is described by - <url href="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</url>.</p> + <url href="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</url>. + Starting from OTP 25.1, the minutes part of the time zone is optional.</p> <p>Valid option:</p> <taglist> <tag><c>{unit, Unit}</c></tag> diff --git a/lib/stdlib/src/calendar.erl b/lib/stdlib/src/calendar.erl index cddb25f55d..e9d3a16dce 100644 --- a/lib/stdlib/src/calendar.erl +++ b/lib/stdlib/src/calendar.erl @@ -718,9 +718,14 @@ offset_string_adjustment(_Time, _Unit, "Z") -> offset_string_adjustment(_Time, _Unit, "z") -> 0; offset_string_adjustment(_Time, _Unit, Tz) -> - [Sign, H1, H2, $:, M1, M2] = Tz, + [Sign, H1, H2 | MinutesDiff] = Tz, Hour = list_to_integer([H1, H2]), - Min = list_to_integer([M1, M2]), + Min = case MinutesDiff of + [$:, M1, M2] -> + list_to_integer([M1, M2]); + [] -> + 0 + end, Adjustment = 3600 * Hour + 60 * Min, case Sign of $- -> -Adjustment; diff --git a/lib/stdlib/test/calendar_SUITE.erl b/lib/stdlib/test/calendar_SUITE.erl index 7bda4ca782..138fdfc086 100644 --- a/lib/stdlib/test/calendar_SUITE.erl +++ b/lib/stdlib/test/calendar_SUITE.erl @@ -281,6 +281,9 @@ rfc3339(Config) when is_list(Config) -> "2000-01-01T10:02:00.000+00:02" = do_format(TO * NaPerSec, [{offset, 120 * NaPerSec}]++Na), + 1656147840 = do_parse("2022-06-25 11:04:00+02", []), + 1656155040 = do_parse("2022-06-25 11:04:00-00", []), + NStr = "2000-01-01T09:58:00-00:02", NStr = do_format(TO, [{offset, -120}]), -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor