Skip to content

Fix NpgsqlDateTime.Add when adding NpgsqlTimeSpan - #3042

Merged
roji merged 1 commit into
npgsql:devfrom
warcha:NpgsqlDateTime.Add_fix
Jun 27, 2020
Merged

roji merged 1 commit into
npgsql:devfrom
warcha:NpgsqlDateTime.Add_fix

Conversation

@warcha

@warcha warcha commented Jun 26, 2020

Copy link
Copy Markdown
Contributor

Fix for Npgsql #3019; Previously, the NpgsqlDateTime.Add with NpgsqlTimeSpan was adding NpgsqlTimeSpan.Ticks to the DateTime, which was incorrect as the Ticks property only returns the ticks in a day and ignores the number of days and months held.

In order to count months and days in the NpgsqlTimeSpan, we need to call TotalTicks after calling UnjustifyInterval (see summary notes for NpgsqlTimeSpan.Ticks)

Also note that 1 month in NpgsqlTimeSpan is the equivalent of 30 days (see summary notes for NpgsqlTimeSpan constant DaysPerMonth)

@warcha
warcha requested review from YohDeadfall and roji as code owners June 26, 2020 06:47
@roji
roji merged this pull request into npgsql:dev Jun 27, 2020
@roji

roji commented Jun 27, 2020

Copy link
Copy Markdown
Member

Merged to dev via 0dc1784
Backported to 4.1.4 via 21bdc52

@roji roji linked an issue Jun 27, 2020 that may be closed by this pull request
@warcha
warcha deleted the NpgsqlDateTime.Add_fix branch August 9, 2020 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix NpgsqlDateTime.Add

2 participants