Commit Graph
109 Commits
Author SHA1 Message Date
Marcos Henrich 137718d9b4 Merge pull request #1321 from esdrubal/currentsystemtimezone
CurrentSystemTimeZone.GetUtcOffset now supports multiple DST periods.
2014-10-28 18:18:54 +00:00
Jonathan Pryor f7fd52ad18 [mscorlib/Android] TimeZoneInfo.Local.Id should be "Local".
On Mono/.NET, TimeZoneInfo.Local has a TimeZoneInfo.Id value of
"Local" and a TimeZoneInfo.DisplayName value of "Local":

	$ csharp
	csharp> TimeZoneInfo.Local.Id;
	"Local"
	csharp> TimeZoneInfo.Local.DisplayName;
	"Local"

That isn't the case on Xamarin.Android, which returns the timezoneinfo
ID value from both DisplayName and Id, e.g. TimeZoneInfo.Local could
have Id and DisplayName values of "Australia/Sydney".

Rework things so that the TimeZoneInfo.Id and TimeZoneInfo.DisplayName
properties return "Local" on Xamarin.Android for the instance returned
from TimeZoneInfo.Local, just like normal Mono/.NET does.
2014-10-24 15:56:13 -04:00
Jonathan Pryor 8b90653ff3 [System.Core/Android] Fix standalone unit tests.
Commit 5564dad1 broke the self-test (for testing on the developer
machine, not an Android target). Fixup the comment so that appropriate
data is grabbed and used for testing, and improve
AndroidTimeZones.GetDefaultTimeZoneName() so that the default timezone
ID can be specified via the __XA_OVERRIDE_TIMEZONE_ID__ environment
variable for testing.

Finally, demonstrate TimeZoneInfo.GetUtcOffset(DateTime) use so that I
can get better insight into the timezone data stored within the
database:

	$ __XA_OVERRIDE_TIMEZONE_ID__=America/New_York ANDROID_ROOT=`pwd` ANDROID_DATA=`pwd` mono --debug tzi.exe --offset=1969-01-01
	Using DateTime Offset: 1/1/1969 12:00:00 AM
	DB type: System.AndroidTzData
	name=Africa/Abidjan                           Africa/Abidjan                          From Offset: 00:00:00
	name=Africa/Accra                             Africa/Accra                            From Offset: 00:00:00
	name=Africa/Addis_Ababa                       Africa/Addis_Ababa                      From Offset: 03:00:00
	...
2014-10-07 13:59:49 -04:00
Marcos Henrich 457c87c69f TimeZoneInfo.CreateLocal now handles environment variable TZ. 2014-10-06 15:57:13 +01:00
Marcos Henrich 2a73a83d89 Use TZ transitions when AdjustementRules are ignored. Fixes 23170.
In some cases the timezone transitions provided by iOS are not convertible to AdjustmentRules because of changes on the base offset.
Now we store the transitions so they can be used instead of an incomplete list of AdjustmentRules.
2014-10-04 17:32:03 +01:00
Marcos Henrich 97c6bc06ea Refactored TimeZoneInfo.GetUtcOffset.
Added GetUtcOffset auxiliar methods with bool out parameter that is true when the given DateTime is a DST.
2014-10-04 16:46:47 +01:00
Marcos Henrich 1a92f4e90b TimeZoneInfo.IsDaylightSavingTime now uses GetUtcOffset. 2014-10-03 17:43:47 +01:00
Marcos Henrich 374e1b13e0 TimeZoneInfo.GetUtcOffset now handles all DateTimeKinds.
Removed GetUtcOffset cohesion with TimeZoneInfo.IsDaylightSavingTime.
2014-10-03 17:43:32 +01:00
Marcos Henrich 09fc592499 Created helper method TimeZoneInfo.IsInDST. 2014-10-03 10:38:13 +02:00
Marcos Henrich 306ac05ea1 Removed repeated logic from TimeZoneInfo.ConvertTimeToUtc. 2014-10-03 10:38:13 +02:00
Marcos Henrich d6848d1ef6 ConvertTimeToUtc no longer relies in DateTime.ToUniversalTime. 2014-10-03 10:38:12 +02:00
Marcos Henrich 9be262f8cc CurrentSystemTimeZone.GetUtcOffset now supports multiple DST periods.
DateTime.Now was returning wrong values when system TimeZone had more than one daylight saving time.
Fixes 22648.
2014-10-02 09:31:06 +01:00
Marcos Henrich 88297792e7 TimeZoneInfo is now always present in corlib.
Prior to net_4_0 TimeZoneInfo is a private class.
2014-10-02 09:31:06 +01:00
Rolf Bjarne Kvinge 550d314e51 Don't throw TimeZoneNotFoundExceptions when iOS gives us invalid data.
iOS 8 GM lists "Asia/Chita" among its time zones, but when requesting
the time zone data for that time zone, no data is returned.

With this change we ignore time zones without any data when fetching
all the timezones on the system.
2014-09-11 19:04:00 +02:00
Sasha Kotlyar 76a25717e7 Miscellaneous changes per review 2014-08-04 19:15:10 -04:00
Sasha Kotlyar a66732c039 [TimeZoneInfo] Fix issue with some floating DST transition times creating invalid DateTime values, and implement ToSerializedString and FromSerializedString.
This change is released under the MIT license.
2014-08-03 15:25:43 -04:00
Rolf Bjarne Kvinge 19f49f93f9 Revert "Revert "Merge branch 'master' of https://github.com/mono/mono""
This reverts commit 8f09dad435.

8f09dad435 is reverting a merge commit,
which will not do what you think it does. It will revert much more,
so revert the revert to get back the unintentionally reverted commits.

It looks like the next commit (1a15d4ec54)
is doing the original intention (reverting 164f9cbec4),
so this revert will leave the tree in a good state, with no pending
reverts.
2014-04-25 16:57:01 +02:00
Alexis Christoforides 8f09dad435 Revert "Merge branch 'master' of https://github.com/mono/mono"
This reverts commit 9dd632fb9e, reversing
changes made to 164f9cbec4.
2014-04-23 14:56:39 -04:00
Marek Habersack 3df23604a4 Correctly apply DST offset if the date being converted falls after Jan 1st and is within the last year's DST zone
The adjustment rule must take into account that DST can start in the previous year and extend to some initial period
of the DateTime's year. This patch makes the code take that into account and correctly applies the DST offset to the
date being converted to some target timezone.

Fixes xambug https://bugzilla.xamarin.com/show_bug.cgi?id=17155
2014-04-23 17:15:18 +02:00
Marek Habersack 44c0689534 A couple of fixes for TimeZoneInfo.ConvertTime.
* ConvertTime (DateTime, TimeZoneInfo) now correctly takes the date kind from the DateTime parameter
      and uses it to select the source time zone according to this criteria:

         if DateTime kind is Utc, use TimeZoneInfo.Utc as source, in all other cases use TimeZoneInfo.Local

    * Move argument checks in ConvertTime (DateTime, TimeZoneInfo, TimeZoneInfo) so that there's no risk of a NREX
      should sourceTimeZone be null.

Added relevant tests for all of the above changes.
2014-04-23 14:53:01 +02:00
Marek Habersack 5564dad150 Fall back to calling Java.Util.TimeZone.Default.ID if the persist.sys.timezone system
property is not present on the system or its value is an empty string. This ensures that
we obtain valid timezone info on systems which do not define the above property.

Part of fix for https://bugzilla.xamarin.com/show_bug.cgi?id=4902
2014-04-16 16:23:16 +02:00
Marek Safar 0c35602a17 [corlib] Implement CultureInfo.ClearCachedData. Fixes #18162 2014-03-05 19:45:28 +01:00
Atsushi Eno b90937ef14 Fix android-specific build (use of unassigned variable). 2013-12-04 01:37:38 +09:00
Alistair Bush 98f1c8c584 Return Local DateTime instead of Unspecified for >net_4_0 2013-10-19 23:41:17 +13:00
Jonathan Pryor 82a197e41c [System.Core/Android] Support Android v4.3's timezone DB format
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=13686

Android v4.3 changed the timezone DB format described in 8a263984 and
replaced it with a single file containing version, index, data, and a
"zoneTab" (which is parsed but unused).

Port/rewrite the Java libcore.util.ZoneInfoDB type into
System.AndroidTzData so that this new file format is supported.

(Another day, another file format...)
2013-08-06 14:27:20 -04:00
Marek Safar 77d2f31ac1 Merge pull request #665 from andreas-auerswald/master
Serilaization TimeZoneInfo class
2013-07-30 06:56:54 -07:00
Andreas Auerswald a4edd897b5 Add TimeZoneInfo Serialization
Add serialization for the TimeZoneInfo, TimeZoneInfo.AdjustmentRule and TimeZoneInfo.TransitionTime class. It is compatible with the serialization in .Net for cross serialization/deserialization from Mono to .Net and vice versa.

The code in this commit is released under the terms of the MIT/X11 license.
2013-07-08 10:39:51 +02:00
Jonathan Pryor ac11abe18d [System.Core/Android] Use correct comparison for timezone ids.
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=7953

The names within zoneinfo.idx are sorted ordinally, which is not the
default string comparison that Array.BinarySearch() uses.
Consequently, many timezones would not be found even though they were
present, including "Pacific/Auckland".

Use the correct string comparison so that names can be found.
2013-06-25 15:51:55 -04:00
Sebastien Pouliot 059406396d [ios] throw an TimeZoneNotFoundException if the timezone name is unknown 2013-05-01 16:19:44 -04:00
Sebastien Pouliot 14b607cf6e Remove reflection usage to access NSTimeZone for iOS 2013-05-01 14:31:05 -04:00
Rodrigo Kumpera 1b92a4148c Since MOBILE implies NET_4_* now, take this into account and simplify our ifdefs. 2013-02-11 18:42:18 -05:00
Rodrigo Kumpera 486ee8d8f4 Kill the MOONLIGHT define in System.Core. 2013-02-11 13:01:10 -05:00
Rodrigo Kumpera 4dc7925783 MOBILE now builds with 4.0 enabled but its version remains 2.0.5.0.
* Consts.cs.in: We must check for mobile before 4.0 to make sure
	we don't end up with a 4.0.0.0 mobile BCL.
2013-01-10 18:13:15 -05:00
Mark Probst bea08c8c43 Properly (?) fix TimeZoneInfo.cs build.
I'm just taking a wild guess that this is the proper fix.  Please review.
2012-12-09 15:00:06 +01:00
Rodrigo Kumpera 6f85c913aa Fix System.Core/System.TimeZoneInfo build under basic profile. 2012-12-07 17:57:34 -05:00
Miguel de Icaza 01ea58cbd4 Merge pull request #487 from mayerwin/patch-1
Update mcs/class/System.Core/System/TimeZoneInfo.cs
2012-12-07 13:59:03 -08:00
technomage 956841a964 [Mono] TimeZoneInfo.FindSystemTimeZoneById returns null
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=7966

If we cannot find the requiested time zone we should throw a
TimeZoneNotFoundException rather than returning null.
2012-12-05 14:24:17 +00:00
Dean Ellis a56f69f82d [Mono] TimeZoneInfo.FindSystemTimeZoneById returns null
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=7966

If we cannot find the requiested time zone we should throw a
TimeZoneNotFoundException rather than returning null.
2012-11-19 21:35:20 +00:00
mayerwin 10eadfdd38 Update mcs/class/System.Core/System/TimeZoneInfo.cs
Implementing missing ConvertTime with DateTimeOffset.
2012-10-27 21:35:56 +08:00
Marek Safar 5fad3b0dce Remove some redundant initializations 2012-10-05 16:37:05 +01:00
Rolf Bjarne Kvinge 142e70fdcc TimeZoneInfo.Local must be cached, otherwise reference comparisons fail later on.
This fixes an issue reported here: http://lists.ximian.com/pipermail/monotouch/2012-September/011784.html
2012-09-17 12:05:43 +02:00
Rolf Bjarne Kvinge 09e213a8b3 Fix typo in exception message. 2012-09-17 12:05:43 +02:00
Atsushi Eno e6a6c31940 in MONODROID profile, TimeZoneInfo should not return null entry. 2012-09-11 21:53:54 +09:00
Adam Brengesjö 8a79da4434 TimeZoneInfo: disable DST if no adjustment rules are given. 2012-06-27 20:26:20 +02:00
Marek Safar 2d84a89a43 Add some new 4.5 api 2012-06-07 11:38:52 +01:00
Miguel de Icaza d7d456d931 Implements TimeZoneInfo.Local for Windows
Fixes #2791, contributed by Jonathan Shore <[email protected]>
2012-01-15 15:10:11 -05:00
Zoltan Varga 4f5152f818 Fix a warning. 2011-12-12 21:03:40 +01:00
Sebastien Pouliot 8e94a7c129 fix typo in monotouch build 2011-11-08 15:56:19 -05:00
Sebastien Pouliot 43bf08bca3 MonoTouch specific initialization for TimeZone (devices). Fix bug #1790 2011-11-08 07:56:40 -05:00
Miguel de Icaza 2852ed0b59 Update copyrights 2011-09-13 18:26:13 -04:00