-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Implement DateTimeOffset.TotalOffsetMinutes #78943
Merged
tarekgh
merged 2 commits into
dotnet:main
from
tarekgh:DateTimeOffset.TotalOffsetMinutes
Nov 29, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the primary purpose of this new property? From the issue description, it seems like it's purely about performance? If so, do we have numbers to validate it is in fact meaningfully better than Offset in the scenarios it'll be used? And out of all the places we use Offset, should any be using this instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I talk about it a bit here in the proposal.
It's been quite a long time- I don't have the exact numbers anymore unfortunately. There are a number of places in the code where we could use this.
https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.cs,1bc976bb59f3dd6e,references
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One interesting data point is that, at least in Azure scenarios,
DateTimeOffset
s are usually UTC. In the index link above there are a few places where we're comparing theOffset
toTimeSpan.Zero
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have liked to see this PR use the new API. Who's following up to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by this PR use the new API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched the who runtime repo and the only files can use the new property are:
runtime\src\libraries\System.Formats.Cbor\src\System\Formats\Cbor\Writer\CborWriter.Tag.cs
runtime\src\libraries\System.Private.Xml\src\System\Xml\Core\XmlWriter.cs
runtime\src\libraries\System.ServiceModel.Syndication\src\System\ServiceModel\Syndication\Atom10FeedFormatter.cs
runtime\src\libraries\System.ServiceModel.Syndication\src\System\ServiceModel\Syndication\Rss20FeedFormatter.cs
If it is worth it, I can try to submit a PR for these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I think if it's worth adding the property, it's worth using it, assuming it makes the usage simpler/faster/etc. I'm pushing on this as I do any time we add API because it helps to validate whether the API is designed correctly and actually worthwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I merged early. I'll try to submit a PR for that in the first chance. Thanks for the follow up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a problem :) It's just one of my pet issues: vetting the APIs we add wherever possible by trying to use them as best as possible in the millions of lines of production library code we maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have opened #79107.