Bug 28716 - DateTime doesn't take account Android time zone settings.
Summary: DateTime doesn't take account Android time zone settings.
Status: RESOLVED DUPLICATE of bug 24947
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 5.2
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-04-03 00:50 UTC by Nicholas Lie
Modified: 2015-04-03 09:45 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Attachment that demonstrates the DateTime timezone issue. (32.55 KB, application/zip)
2015-04-03 00:50 UTC, Nicholas Lie
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 24947

Description Nicholas Lie 2015-04-03 00:50:19 UTC
Created attachment 10615 [details]
Attachment that demonstrates the DateTime timezone issue.

It seems that the DateTime does not take account Android timezone settings.

I've attached a sample that replicates this issue, but you will need to deploy this on a device.

Steps to replicate:
1. Click the "DateTime issue" button, it will show the current time using DateTime.Now.
2. Make a note of that time.
3. Without closing the app, swipe up from the screen and access Settings page, scroll down to the Date and Time settings.
4. Change the timezone to any other timezone that you're currently in. 
5. Leave the automatic time zone off.
6. Return to the app.
7. Click the "DateTime issue" button again, and it will still show the old time, without taking account the new timezone.

I have to do a workaround for now to get the current datetime correctly with respect to Android's timezone settings, demonstrated in the "Get Current Java Time" button.

Now I can't rely on the DateTime struct anymore, which is highly problematic. I'm pretty sure ToLocalTime() also works incorrectly. Please help fix this bug ASAP since my current infrastructure relies heavily on time zone settings. This can also affect the synchronization process I have in the current app. Simply said, the current DateTime struct does not allow the user to travel from one place to another across multiple timezones.

My current configuration:
Xamarin Studio
Version 5.8.2 (build 7)
Installation UUID: 03e3ce2d-0205-4d25-ab29-565e23b9760e
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

Apple Developer Tools
Xcode 6.2 (6776)
Build 6C131e

Xamarin.Mac
Not Installed

Xamarin.iOS
Version: 8.8.2.4 (Business Edition)
Hash: 981acb3
Branch: 
Build date: 2015-03-25 14:21:05-0400

Xamarin.Android
Version: 4.20.1.0 (Business Edition)
Android SDK: /Developer/android-sdk
	Supported Android versions:
		2.2    (API level 8)
		2.3    (API level 10)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

Xamarin Android Player
Not Installed

Build Information
Release ID: 508020007
Git revision: 067ed06873402cf780f8a0899bb332c2a1c0af22
Build date: 2015-03-27 14:17:13-04
Xamarin addins: 02510c4990dee3475c282b3182d588975a63ff07

Operating System
Mac OS X 10.10.2
Darwin Nicholass-MacBook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0
    Thu Feb 26 19:26:47 PST 2015
    root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
Comment 1 Atin 2015-04-03 06:03:39 UTC
I have checked this issue and able to reproduce this issue with the help of attached sample and steps getting same behaviour as mentioned in bug description.I check this issue on XAP and Samsung note3 and I get the same behaviour .Here is the screencast when I run project on XAP

Screencast:  http://www.screencast.com/t/ZQTVToHZ8v
Ide Logs: https://gist.github.com/Shruti360/e5b53838a4ab56234405

Environment info:

=== Xamarin Studio ===

Version 5.8.2 (build 7)
Installation UUID: 67eaf3b4-f8a7-4ab4-a9df-3197350ca5dc
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

=== Apple Developer Tools ===

Xcode 6.2 (6770)
Build 6C121

=== Xamarin.iOS ===

Version: 8.8.2.4 (Enterprise Edition)
Hash: 981acb3
Branch: 
Build date: 2015-03-25 14:21:05-0400

=== Xamarin.Android ===

Version: 4.20.1.0 (Enterprise Edition)
Android SDK: /Users/ixamarin78/Desktop/android-sdk-macosx
	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.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.12.0.14 (Enterprise Edition)

=== Build Information ===

Release ID: 508020007
Git revision: 067ed06873402cf780f8a0899bb332c2a1c0af22
Build date: 2015-03-27 14:17:13-04
Xamarin addins: 02510c4990dee3475c282b3182d588975a63ff07

=== Operating System ===

Mac OS X 10.10.0
Darwin XamnewiMac.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Jonathan Pryor 2015-04-03 09:45:22 UTC

*** This bug has been marked as a duplicate of bug 24947 ***