Skip to content

Commit

Permalink
Fix #507 - unnecessary tz conversion during logical shifts results in…
Browse files Browse the repository at this point in the history
… erroneous results
  • Loading branch information
bitwalker committed Jun 27, 2019
1 parent 3fd2804 commit f96d0ae
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/datetime/datetime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,7 @@ defimpl Timex.Protocol, for: DateTime do
def shift(%DateTime{time_zone: tz, microsecond: {_us, precision}} = datetime, shifts) when is_list(shifts) do
{logical_shifts, shifts} = Keyword.split(shifts, [:years, :months, :weeks, :days])
incoming_tzinfo = Timex.timezone(tz, datetime)
datetime =
datetime
|> Timezone.convert("Etc/UTC")
|> logical_shift(logical_shifts)
datetime = logical_shift(datetime, logical_shifts)
us = to_gregorian_microseconds(datetime)
shift = calculate_shift(shifts)
shifted_us = us + shift
Expand Down

0 comments on commit f96d0ae

Please sign in to comment.