Bug 13686 - Problems with System.TimeZoneInfo
Summary: Problems with System.TimeZoneInfo
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.8.x
Hardware: Macintosh Mac OS
: Highest normal
Target Milestone: 4.8.2 (Android 18)
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-08-01 13:53 UTC by Neal
Modified: 2013-08-23 13:55 UTC (History)
5 users (show)

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


Attachments
sample app (12.39 KB, application/zip)
2013-08-01 14:00 UTC, Neal
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:
VERIFIED FIXED

Description Neal 2013-08-01 13:53:02 UTC
Hello,

I'm still investigating but it appears with Android 4.3 and/or Mono for Android 4.8.x (I have 4.8.1 beta installed now) that System.TimeZoneInfo is not working.  For example, if I try to return TimeZoneInfo.Local.StandardName it errors out.
Comment 1 Neal 2013-08-01 14:00:43 UTC
Created attachment 4514 [details]
sample app
Comment 2 Neal 2013-08-01 14:00:52 UTC
this is a show stopper for me.  Please fix ASAP.  See sample app attached.
Comment 3 Jonathan Pryor 2013-08-01 14:40:52 UTC
What is the output of:

    adb shell getprop persist.sys.timezone

If it prints nothing, then this is Bug #4902.

What device is this? What stack trace does it generate?
Comment 4 Neal 2013-08-01 14:47:23 UTC
It's a Jelly bean 4.3 emulator, I'll try to get the other info you need now.  I included a sample if you can run it against a 4.3 emulator, I'm using the Mac if that matters.
Comment 5 Neal 2013-08-01 15:10:58 UTC
The message + exception is:

Object reference not set to an instance of an object
  at XamSample.MainActivity+<OnCreate>c__AnonStorey0.<>m__0 (System.Object , System.EventArgs ) [0x0000d] in /Users/Neal/Dev/XamSample/XamSample/MainActivity.cs:35

I don't know how to run adb on a Mac.  If you want to walk me through it reply with info or call me at 323-1223
Comment 6 Jonathan Pryor 2013-08-01 15:18:22 UTC
By default,the Android SDK is installed into:

    $HOME/Library/Developer/Xamarin/android-sdk-mac_x86

Thus, please open Terminal.app, then:

    cd $HOME/Library/Developer/Xamarin/android-sdk-mac_x86/platform-tools
    ./adb shell getprop persist.sys.timezone
Comment 7 Neal 2013-08-01 15:26:38 UTC
Jon,

I ran that command and I get "America/New_York

But I'm not sure what this is for, I do have the emulator running but am I in fact getting the value from the emulator?
Comment 8 Neal 2013-08-01 15:29:08 UTC
I did a ./adb devices and it shows the emulator, it again returned America/New_York

Did you try the sample against Android 4.3 and repro the issue by any chance?
Comment 9 Jonathan Pryor 2013-08-01 15:30:58 UTC
If you don't have a hardware device plugged in, then `adb` will connect to your emulator. If you did have both the emulator running and a device plugged in, you'd get an error asking you to specify a target to connect to.

> Did you try the sample against Android 4.3 and repro the issue by any chance?

Not yet.
Comment 10 Neal 2013-08-01 17:07:31 UTC
Jon,

I tested against gingerbread (2.3.3 api 10) and it works fine.  It seems to be isolated to Android 4.3 (18)
Comment 11 Neal 2013-08-02 07:59:11 UTC
Please see bugzilla case 7953 as it may be similar and still need to be fixed?
Comment 12 Neal 2013-08-02 09:51:15 UTC
GetSystemTimesZones is also dead.
Comment 14 horizoniosdev 2013-08-02 10:57:11 UTC
FWIW:

- I also see the bug on an Android 4.3 Nexus 4.

- My device correctly returns my timezone with "adb shell getprop persist.sys.timezone"

- You can test for the bug in one line of code in any app:

var offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now.AddDays(10))

in the example above, ".Local" will be null

- My deployed app in store is now trashed on 4.3 devices because of this bug (if that helps anybody prioritize)

- This bug affects the popular ServiceStack.Text library which makes use of the TimeZone lookup
Comment 15 Jonathan Pryor 2013-08-02 14:53:40 UTC
Google/Android changed their timezone info file format. It used to consist of the files $ANDROID_ROOT/usr/share/zoneinfo/zoneinfo.dat and $ANDROID_ROOT/usr/share/zoneinfo/zoneinfo.idx.

Now, none of those exist, and instead it's $ANDROID_ROOT/usr/share/zoneinfo/tzdata.

Looks like we need to port: https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/ZoneInfoDB.java
Comment 16 Jonathan Pryor 2013-08-06 14:47:25 UTC
Mono has Android v4.3 tzdata support as of mono/82a197e4:

https://github.com/mono/mono/commit/82a197e41c9eeb12f1203c65bcb40567481ecad3

Fixed in monodroid/33e5abc7.
Comment 17 Mohit Kheterpal 2013-08-23 13:55:28 UTC
Today we are try to verify this issue with following builds :

XS 4.1.9(build 7)
X.Android 4.8.02054
Mono 3.2.2

When we run the attached sample application in comment 1 on Device(4.3), It deploy successfully without any error and "Hello world click me button appears" and when we click on this button it converts its into "IST" button.

I am not sure about the correct behavior. Please suggest if a miss something to check.