Skip to content

Commit 9752f1c

Browse files
dcuddebackmichalmuskala
authored andcommitted
Optimize ISO-8601 parsing for UTC
1 parent 06e5ec2 commit 9752f1c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/elixir/lib/calendar/datetime.ex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,24 @@ defmodule DateTime do
525525
not calendar.valid_time?(hour, minute, second, microsecond) ->
526526
{:error, :invalid_time}
527527

528+
offset == 0 ->
529+
datetime = %DateTime{
530+
calendar: calendar,
531+
year: year,
532+
month: month,
533+
day: day,
534+
hour: hour,
535+
minute: minute,
536+
second: second,
537+
microsecond: microsecond,
538+
std_offset: 0,
539+
utc_offset: 0,
540+
zone_abbr: "UTC",
541+
time_zone: "Etc/UTC"
542+
}
543+
544+
{:ok, datetime, 0}
545+
528546
is_nil(offset) ->
529547
{:error, :missing_offset}
530548

0 commit comments

Comments
 (0)