Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Move parse_timzeone_offset into PersonIdent. #197

Merged
merged 1 commit into from
Oct 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/xgit/core/person_ident.ex
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ defmodule Xgit.Core.PersonIdent do
case {time, tz} do
{[_ | _], [_ | _]} ->
{time |> ParseDecimal.from_decimal_charlist() |> elem(0),
tz |> RawParseUtils.parse_timezone_offset() |> elem(0)}
tz |> parse_timezone_offset() |> elem(0)}

_ ->
cover {0, 0}
Expand All @@ -162,7 +162,16 @@ defmodule Xgit.Core.PersonIdent do
|> Enum.take_while(&(&1 != ?\s))
|> Enum.reverse()

{word, Enum.drop(rev, Enum.count(word))}
cover {word, Enum.drop(rev, Enum.count(word))}
end

defp parse_timezone_offset(b) do
{v, b} = ParseDecimal.from_decimal_charlist(b)

tz_min = rem(v, 100)
tz_hour = div(v, 100)

cover {tz_hour * 60 + tz_min, b}
end

@doc ~S"""
Expand Down