Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report for Bug 15134 on
GitHub or Developer Community if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Created attachment 5040 [details]
I'm using DateTime.ToLocalTime() in an iOS library and it's returning
unexpected results. The time doesn't seem to change to match the timezone
but the Kind is being set to Local.
I've posted an example on StackOverflow.com
Is this expected behaviour?
After further investigation this appears to be confined to dates before
1970 (note that BST started in 1916).
Please find attached:
- A sample project that outputs all the timezone and datetime
information (rename .zipped to .zip)
- A screenshot of it running on my mac (iOS Simulator)
- A copy of my 'About' information.
This is to be a very serious problem and means that all 'Date of births' in
my app are shown incorrectly as they are derived from UTC date strings.
In the screenshot you'll notice that the 'Daylight savings time for year
1970' is incorrect.
Created attachment 5041 [details]
Paolo, looks like this commit you made a long time ago is the source of this bug:
Here is a test case: https://gist.github.com/rolfbjarne/e599168fe2aba6b47353 - executing it will clearly show that there is no summertime information from before 1970.
While we implement a complete fix for this, you can use the following workaround for DateTime.ToLocalTime():
Datetime localdate = TimeZoneInfo.ConvertTime (utcdate, TimeZoneInfo.Utc, TimeZoneInfo.Local);
The workaround does not work. It results in the same issue.
I've added the following lines to the original sample project.
// 1960 (2)
utcDateTime = new DateTime (1960, 07, 15, 15, 00, 00, DateTimeKind.Utc);
utcTimeString = utcDateTime.ToString ();
var localdate = TimeZoneInfo.ConvertTime (utcDateTime, TimeZoneInfo.Utc,TimeZoneInfo.Local);
localTimeString = localdate.ToString ();
Both the localTimeString and utcTimeString result in "7/15/1960 3:00:00 PM", which is incorrect. localTimeString should be "7/15/1960 4:00:00 PM"
Chris: what is the mono version and the platform version this is being run on?
TimeZoneInfo needs the zoneinfo data to be available (Android, Linux, OSX).
I had tested the workaround on my system with a date from 1918 and it was fine.
I'm running under iOS and have tested in both simulator and device.
I have updated my system since the original version information was attached, so here it is again:
=== Xamarin Studio ===
Version 4.0.13 (build 38)
Installation UUID: 4e7a8b28-b1e8-4f65-9910-dd21d038725e
Mono 3.2.3 ((no/8d3b4b7)
GTK+ 2.24.20 theme: Raleigh
Package version: 302030000
=== Apple Developer Tools ===
Xcode 5.0.1 (3335.23)
=== Xamarin.iOS ===
Version: 220.127.116.11 (Business Edition)
Build date: 2013-04-10 18:05:51-0400
=== Xamarin.Android ===
Version: 4.8.3 (Starter Edition)
Android SDK: /Users/chriskoiak/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
2.1 (API level 7)
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
4.0 (API level 14)
4.0.3 (API level 15)
4.2 (API level 17)
Java SDK: /usr
No Java runtime present, requesting install.
=== Xamarin.Mac ===
Xamarin.Mac: Not Installed
=== Build Information ===
Release ID: 400130038
Git revision: 07afec667f7be5d0ee511eb7115bbac6377fbae8
Build date: 2013-09-24 08:53:29+0000
Xamarin addins: 61140345a5b109633a94409edcbc7a4c19a425c6
=== Operating System ===
Mac OS X 10.9.0
Darwin Chriss-MacBook-Pro-2.local 13.0.0 Darwin Kernel Version 13.0.0
Thu Sep 19 22:22:27 PDT 2013