Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mobile] DateTime.Now returns incorrect local time for one hour after entering DST in 39 locales. #16395

@jgold6

Description

@jgold6

Steps to Reproduce

  1. Open the attached test project
  2. Set the device time on your target device to 3/8/2020 2:00 AM Central Standard Time. Note that it jumps to 3:00 AM as there is no 2:00 AM on 3/8/2020.
    If deploying to a simulator, you will have to set the time on the host workstation to set the system time for an emulator or simulator, whether iOS or Android. depending on the device/workstation, you may not be able to directly select Central Standard Time for the time zone, but may have to select, e.g. Kansas City, MO. Worth noting is that CST in Canada works correctly, and it is only CST in the US where this issue occurs, along with 38 other locales noted below.
  3. Deploy the test app to your target device.
  4. Observe the time in the app UI compared to the system time in the device status bar.

DateTimeNowDSTTest.zip

Current Behavior

Time shown is one hour earlier than is shown by the system time.

Expected Behavior

Time shown in the app matches the system time in the system status bar.

Notes

Although this issue only occurs on Xamarin.iOS and Xamarin.Android, it is a mono issue.
I reported this issue against Xam.iOS and Xam.Android in two DevDiv reports (958935 and 958936), and an iOS engineer (@mandel-macaque ) confirmed this is a mono issue and believes he identified the problem area. Thus I am opening this new issue against Mono and will be closing the DevDiv issues against XI and XA.
This issue has been reported for other locales and DST change times/dates in this closed mono issue:
#9664
Initially the above issue was about 2019 Spring and Fall changeovers. The Fall 2019 DST changeover seems to be correct, but I still notice issues for Spring 2020 as noted below.

Affected locales and details of when changeover is supposed to occur for each locale:

Cuba, Havana (Cuba Standard Time):    Jumps ahead at 12:00 AM on 3/8/2020 to 1:00 AM
US, Kansas City, MO (US Central Time):    Jumps ahead at 2:00 AM on 3/8/2020 to 3:00 AM
Anchorage, AK (Alaska Time):    Jumps ahead at 2:00 AM on 3/8/2020 to 3:00 AM
Azores ST (Ponta Delgada, Portugal):    Jumps ahead at 12:00 AM on 3/29/2020 to 1:00 AM
Iran, Tehran (Iran ST):    Jumps ahead at 12:00 AM on 3/21/2020 to 1:00 AM
Israel, Jerusalem (Israel ST):    Jumps ahead at 2:00 AM on 3/27/2020 to 3:00 AM
Jordan, Amman (Eastern European ST):    Jumps ahead at 12:00 AM on 3/27/2020 to 1:00 AM
Albania, Tirana (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Austria, Vienna (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Belgium, Brussels (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Bulgaria, Sofia (Eastern European ST):    Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
Czechia, Prague (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Denmark, Copenhagen (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Estonia, Tallinn (Eastern European ST):    Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
France, Paris (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Germany, Berlin (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Greece, Athens (Eastern European ST):    Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
Guernsey (UK) - cannot find in macOS time zone settings - tested only in Android:    Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
Holy See, Vatican City (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Hungary, Budapest (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Ireland, Dublin (Greenwich Mean Time -> Irish Standard Time):    Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
UK, Douglas, Isle of Man (GMT+1:00):    Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
Italy, Rome (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Jersey (UK) - cannot find in macOS time zone settings - tested only in Android:    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Latvia, Riga (Eastern European ST):    Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
Lithuania, Vilnius (Eastern European ST):    Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
Luxembourg, Luxembourg (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Malta, Valletta (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Moldova, Chişinău (Eastern European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Monaco, Monaco (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Netherlands, Amsterdam (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Norway, Oslo (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Poland, Warsaw (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Portugal, Lisbon (Western European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
San Marino, San Marino (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Slovakia, Bratislava (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Spain, Madrid (Central European ST):    Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
Ukraine, Kiev (Eastern European ST):    Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
United Kingdom, London (British ST):    Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM

On which platforms did you notice this

Issue does not occur when using Desktop Mono. See notes above.

[ ] macOS
[ ] Linux
[ ] Windows
[x] iOS
[x] Android

Version Used:

Mono 6.0.0.319
Also tested Mono 6.4.0.81

Xam.Android: Version: 9.4.1.0
Also tested: 9.5.0.27

Xamarin.iOS: Version: 12.14.0.114
Also tested: 12.16.0.5

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions