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

Incorrect DateTime.Now for Casablanca (Marocco) TimeZone #21177

Open
mandel-macaque opened this issue Aug 2, 2021 · 8 comments
Open

Incorrect DateTime.Now for Casablanca (Marocco) TimeZone #21177

mandel-macaque opened this issue Aug 2, 2021 · 8 comments

Comments

@mandel-macaque
Copy link
Member

Original source of this issues is from a feedback ticket that was added to Xamarin.iOS yet we do not implemente the TZ code and we use the bcl. The original source is https://developercommunity.visualstudio.com/t/Incorrect-DateTimeNow-for-Casablanca-M/1476956

[severity:I’m unable to use this version]
We are the developing the mobile application using xamarin forms and we are calling DateTime.Now in several places of the app to get the current date time. But DateTime.Now is returning the wrong Date Time, if we set the timezone of the IPad to Marocco,Casablanca.

Example.
if device time is 2PM(this can be verified in settings app of Ipad/in the status bar) then in the app we see 1PM but it should be 2PM.

Repro steps:
1.Open Settings app in Ipad/Iphone and search for date time.
2.Select date time and change the time zone to Marocco,Casablanca.
3.Call DateTime.Now in the Xamarin forms app and observe the date Time returned.

Issue: DateTime.Now is returning wrong time(ex. if device time is 2PM it returns 1PM).
expected Result:DateTime.Now should return the value which should match with device datetime

FYI:
This is blocking us from rolling out app to our client who are using Marocco,Casablanca time zone.
We are expecting fix for this issue or we need a work around to overcome this issue.

@lambdageek
Copy link
Member

Related issue #20510

@lambdageek
Copy link
Member

#20510 (comment)

so either the data we get is stale, or we parse it badly in ParseTZBuffer

Relatedly, there were some issues like tzinfo/tzinfo#98 and tzinfo/tzinfo#123 seem to point to something funny in the 2018e tzdata database tzinfo/tzinfo@246d5ba

We might need similar changes in our parsing code, assuming something similar is going on and that the data on iphones has the updated timezone info for Casablanca.

@lewing
Copy link
Member

lewing commented Aug 31, 2021

cc @eerhardt just in case he is familiar with issues there.

@eerhardt
Copy link
Contributor

Africa/Casablanca is a super hard time zone, we even have specific tests for it in dotnet/runtime.

One issue I know of is: dotnet/runtime#31331 (comment). In this case we were throwing an exception when parsing the TZ file, and thus turning off DST, which is obviously not going to produce the correct time when in daylight savings time.

@lambdageek
Copy link
Member

Africa/Casablanca is a super hard time zone, we even have specific tests for it in dotnet/runtime.

One issue I know of is: dotnet/runtime#31331 (comment). In this case we were throwing an exception when parsing the TZ file, and thus turning off DST, which is obviously not going to produce the correct time when in daylight savings time.

Thanks @eerhardt that was super-helpful!

Comparing the mono/mono parsing logic and what's in dotnet/runtime, it looks like mono/mono only reads the V1 tzfile data (which is probably incomplete or only covers a limited time period - I haven't checked the contents yet).

@kiranbasvaraj
Copy link

Team,
Any findings or progress on this?

@lambdageek
Copy link
Member

No update.

@mandel-macaque is there an iOS API that can be used to get the time that could be used instead of DateTime.Now as a workaround?

@eerhardt
Copy link
Contributor

eerhardt commented Feb 9, 2022

I'm curious, if you try .NET MAUI, do you get the correct time?

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

No branches or pull requests

5 participants