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

TimeZones and DateTimeOffset #360

Open
vsfeedback opened this issue Nov 27, 2019 · 1 comment
Open

TimeZones and DateTimeOffset #360

vsfeedback opened this issue Nov 27, 2019 · 1 comment
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.DateTime
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


Currently DateTimeOffset is lacking in Options for Time Zone conversions and the windows api for TimeZoneInfo has no support for DateTimeOffset

this leads to having to write code to convert a datetime offset to a date time then useing TimeZoneInfo to convert to a new Datetime and then back to a DateTimeOffset so that the intended point in time and time zone are perserved.

this set of conversions between formats and the related api calls creates the possiblity of errors in conversion that may not be easy to spot if the developer is not fully versed in the details of time zones.

i think that a new set of methods or a new class library be created that unify the TimeZoneInfo and DateTimeOffset to allow a developer to ask that a datetimeoffset be converted to a new timezone and not need to get into a chain of conversions. this would reduce errors and make use of DateTimeOffset simpler for most developers


Original Comments

Denny Figuerres on 3/15/2019, 08:16 AM:

also DateTimeOffset ToLocal assume the servers date time / timezone which does not give any option to convert to a users time zone for an application on the web, the client may be in a different timezone than the browser client.

and a browser may need to see a date for a timezone they are not in.

Jane Wu [MSFT] on 3/18/2019, 01:36 AM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We'll provide an update once the issue has been triaged by the product team.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Runtime untriaged New issue has not been triaged by the area owner labels Nov 27, 2019
@Clockwork-Muse
Copy link
Contributor

also DateTimeOffset ToLocal assume the servers date time / timezone which does not give any option to convert to a users time zone for an application on the web, the client may be in a different timezone than the browser client.

and a browser may need to see a date for a timezone they are not in.

This. This is why DateTimeKind is broken. Utc/Local/Unknown (or Other in similar APIs) show a misunderstanding of the domain.

I will reiterate that we should provide a first-party complete, modern, date/time API, that would look similar to java.time and NodaTime.
Note that in most cases DateTimeOffset is also not the proper domain type, as non-absolute-instant information is usually better recorded as a DateTimeZoned (which automatically updates the offset when adding any time).

@joperezr joperezr added api-needs-work API needs work before it is approved, it is NOT ready for implementation api-suggestion Early API idea and discussion, it is NOT ready for implementation and removed untriaged New issue has not been triaged by the area owner labels Jul 7, 2020
@joperezr joperezr added this to the Future milestone Jul 7, 2020
@terrajobst terrajobst removed the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.DateTime
Projects
None yet
Development

No branches or pull requests

6 participants