Bug 18804 - Cannot get TimeZone to show long name instead of abbreviation (Xamarin Android)
Summary: Cannot get TimeZone to show long name instead of abbreviation (Xamarin Android)
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: master
Hardware: PC Windows
: Normal enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-04-03 16:14 UTC by psamizadeh
Modified: 2014-04-04 11:44 UTC (History)
5 users (show)

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


Attachments

Description psamizadeh 2014-04-03 16:14:26 UTC
I'm trying to get the long name for the timezone from System.TimeZone. This is how I'm trying to do it:

Console.WriteLine(System.TimeZone.CurrentTimeZone.DaylightName);
And the result that i'm getting in console is:

EST

But what I need is the long name:

Eastern Standard Time

I looked into C# documentation (http://msdn.microsoft.com/en-us/library/system.timezone.currenttimezone(v=vs.110).aspx) and noticed that the .Net library is returning what I need but for some reason Xamarin (mono) just gives me the abbreviation.
Comment 1 Shruti 2014-04-04 02:17:57 UTC
I have checked this issue and able to reproduce  it. Steps are:

1. Created an android project.
2. Added code of TimeZone as mentioned above.
3. Build and deploy it.

Actual Result : IST 
Expected Result : India Daylight Time


Screencast info : 
http://screencast.com/t/BpBUcrOd

Environment Info:
=== Xamarin Studio ===

Version 4.2.3 (build 60)
Installation UUID: 400bab6b-f5cd-4e84-a1d1-39f9d6414cb1
Runtime:
	Microsoft .NET 4.0.30319.18449
	GTK+ 2.24.22 theme: MS-Windows
	GTK# (2.12.0.0)

=== Xamarin.Android ===

Version: 4.12.2 (Trial Edition)
Android SDK: E:\SDK\AndroidSDK
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		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)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)

=== Build Information ===

Release ID: 402030060
30c4afc300c2a39ec5300851357ce02e49dd217e
Build date: 2014-03-05 16:53:54Z
Xamarin addins: f8a9589b57c2bfab2ccd73c880e7ad81e3ecf044

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 2 Jonathan Pryor 2014-04-04 11:44:36 UTC
> Xamarin (mono) just gives me the abbreviation.

Implementation details ;-)

Mono uses strftime(3) in order to obtain the timezone name, and strftime(3) only provides a single way to get the timezone name, which always provides the abbreviation, not the 'long" name:

https://github.com/mono/mono/blob/master/mcs/class/corlib/System/TimeZone.cs#L76
https://github.com/mono/mono/blob/master/mono/metadata/icall.c#L6017
http://linux.die.net/man/3/strftime

Consequently, there is no way for Mono to provide longer timezone names without separately creating and including a timezone database.

This is also the behavior on desktop mono:

$ csharp
csharp> TimeZone.CurrentTimeZone.DaylightName; 
"EDT"

Furthermore, System.TimeZoneInfo is no better in this regard (on OS X, anyway), providing the abbreviations and not the full names, because timezone DB doesn't contain that information. (zone.tab appears to, maybe, but the compiled e.g.  /usr/share/zoneinfo/America/New_York file does not.)

Note You need to log in before you can comment on or make changes to this bug.