Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make BclDateTimeZone behave more reasonably for midnight transitions #1527

Merged
merged 1 commit into from May 2, 2020

Conversation

jskeet
Copy link
Member

@jskeet jskeet commented May 2, 2020

Transitions that would be represented as 24:00 in the IANA time zone database are represented as 23:59:59.999 in the Windows database. It makes sense to correct this as we have the facility to do so; the intent of the data is clearly "one millisecond later" even though that's not what the Windows rule actually says. (I don't think anyone would argue that the transition actually happens when the Windows rule says it does.)

Fixes #1524.

@jskeet jskeet requested a review from malcolmr May 2, 2020 09:15
Copy link
Contributor

@malcolmr malcolmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

var expectedFallBack = Instant.FromUtc(2012, 2, 26, 2, 0, 0);
var expectedSpringForward = Instant.FromUtc(2012, 10, 21, 3, 0, 0);

// We assume that the fall-back happens before the spring-forward in the dates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfinished comment? (Also, do we have to assume anything? This test is for a concrete situation.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will address.

Assert.AreEqual(expectedSpringForward, nodaTzdbInterval.End);

// Check that the real BCL time zone behaves as reported in the issue: the transitions occur one millisecond early
var rules = bclZone!.GetAdjustmentRules();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really related to this change, but I'm trying to understand why the null-forgiving operator is needed? From what I can see, the only useful use of this would be if we have an explicitly-nullable reference type (TimeZoneInfo?), but we don't?

(I'm looking at https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references#nullable-annotation-context for reference.)

(Likewise a little bit below.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are - it's not now. It was in an earlier version. The local variable isn't needed either! (Was just useful when debugging)

Transitions that would be represented as 24:00 in the IANA time zone database are represented as 23:59:59.999 in the Windows database. It makes sense to correct this as we have the facility to do so; the intent of the data is clearly "one millisecond later" even though that's not what the Windows rule actually says. (I don't think anyone would argue that the transition actually happens when the Windows rule says it does.)

Fixes nodatime#1524.
@jskeet
Copy link
Member Author

jskeet commented May 2, 2020

Fixed the little problems; will merge on green.

@codecov-io
Copy link

Codecov Report

Merging #1527 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1527   +/-   ##
=======================================
  Coverage   99.23%   99.23%           
=======================================
  Files         153      153           
  Lines        6812     6817    +5     
=======================================
+ Hits         6760     6765    +5     
  Misses         52       52           
Impacted Files Coverage Δ
src/NodaTime/TimeZones/BclDateTimeZone.cs 80.76% <100.00%> (+0.76%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 38d130f...8819d9b. Read the comment docs.

@jskeet jskeet merged commit c0cd310 into nodatime:master May 2, 2020
@jskeet jskeet deleted the issue1524 branch May 2, 2020 12:18
malcolmr added a commit to malcolmr/nodatime.org that referenced this pull request May 2, 2020
- Document the potential for the removal of the
  `AllowPartiallyTrustedCallers` attribute to be a breaking change (if
  using .NET Framework and relying upon it, though it's still not
  actually clear to me how the 'new' security model works).
- Document the (extremely minor) behaviour change introduced in
  nodatime/nodatime#1527.
jskeet pushed a commit to nodatime/nodatime.org that referenced this pull request May 2, 2020
- Document the potential for the removal of the
  `AllowPartiallyTrustedCallers` attribute to be a breaking change (if
  using .NET Framework and relying upon it, though it's still not
  actually clear to me how the 'new' security model works).
- Document the (extremely minor) behaviour change introduced in
  nodatime/nodatime#1527.
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.

TimeZone.AtStartofDate for day with switch to DLS in Brazil
3 participants