Bug 23664 - DateTime.Now issue
Summary: DateTime.Now issue
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.18.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2014-10-07 06:37 UTC by Rodolfo Redolfi
Modified: 2014-10-14 08:18 UTC (History)
3 users (show)

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

Sample project reproducing the issue (11.31 KB, application/zip)
2014-10-07 10:35 UTC, Rodolfo Redolfi

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 for Bug 23664 on Developer Community or GitHub 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 original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Rodolfo Redolfi 2014-10-07 06:37:59 UTC
I'm developing a field automation application running on Nexus 7.
Until my internal build 21 (29/08/2014), DateTime.Now worked corectly.
After build 22 (04/09/2014), the time retrieved doesn't account for the daylight save offest (I'm in Itally, currently GMT+1 plus one hour for the dalylight save), so in a hurry I've created a function that returns the correct value ( return(DateTime.Now.Add(System.TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year).Delta));) that works correctly.
This morning I saw the last Xamarin update addressing an issue related to DateTime and daylight save in some zones, and thinking it was the solution to my issue I've updated my environment, but after having cleaned and rebuilt the whole project nothing changed.
If should I check or try something, please let me know.

Comment 1 Arpit Jha 2014-10-07 09:27:28 UTC
I have checked this issue and unable to reproduce it.

I observed that 
	DateTime dtnow = DateTime.Now;

			DateTime dt	=DateTime.Now.Add (System.TimeZone.CurrentTimeZone.GetDaylightChanges (DateTime.Now.Year).Delta);

Both Datetime object return Same time.
Device TimeZone : Kolkata GMT+5.30
Coluld you please provide us Sample project ,Build Info and Environment Info So that I Can able to reproduce at my end.
Let me know if I missed anything to reproduce it.

Screencast regarding Same :

Enviroment Info:
XS 5.5 (build 227)
Comment 2 Rodolfo Redolfi 2014-10-07 10:35:16 UTC
Created attachment 8337 [details]
Sample project reproducing the issue

The sample project reproduce the issue on my devices (Nexus 7 and Samsung Note 10.1); my personal opinion is that this could be related to the timezone, and/or the way daylightsave deltas or start / end dates are retrieved.
Comment 3 Rodolfo Redolfi 2014-10-07 11:06:11 UTC
=== Xamarin Studio ===

Version 5.5 (build 227)
Installation UUID: b366c44a-552c-4074-9138-ff0ca63727f8
	Microsoft .NET 4.0.30319.18444
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.18.0 (Business Edition)
Android SDK: C:\Users\Rodolfo\AppData\Local\Android\android-sdk
	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.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
Java SDK: C:\Program Files\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)

=== Build Information ===

Release ID: 505000227
Git revision: 7b721eeec7a2fa4c4f4de0ecd2aed4dc25edac95
Build date: 2014-10-02 15:51:22-04
Xamarin addins: 99ed56b428b31eba1efaace4d82188d6f334e6ca

=== Operating System ===

Windows 6.1.7601.65536
Comment 4 Arpit Jha 2014-10-08 02:09:44 UTC
I have checked this issue and able to reproduce it with the help of Comment 2 and bug description.

I observed that GMT +1 Time zone return 1 hour difference in time for 
and DateTime.Now  but for another time zone both code return same Datetime.

Screencast regarding Same :
Environment Info:
VS 2013 professional Update3