Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne
Last active January 21, 2016 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolfbjarne/8a2d635e5c49168c44ca to your computer and use it in GitHub Desktop.
Save rolfbjarne/8a2d635e5c49168c44ca to your computer and use it in GitHub Desktop.
public static void Test ()
{
Console.WriteLine ("Abbreviations:");
foreach (var abbr in NSTimeZone.Abbreviations) {
Console.WriteLine (" {0}", abbr);
}
Console.WriteLine ("KnownTimeZoneNames:");
foreach (var name in NSTimeZone.KnownTimeZoneNames) {
Console.WriteLine (" {0}", name);
}
DumpTZ (NSTimeZone.SystemTimeZone, "SystemTimeZone");
DumpTZ (NSTimeZone.DefaultTimeZone, "DefaultTimeZone");
DumpTZ (NSTimeZone.LocalTimeZone, "LocalTimeZone");
DumpTZ (NSTimeZone.FromName ("Europe/Berlin"), "Europe/Berlin");
DumpTZ (NSTimeZone.FromAbbreviation ("MEZ"), "MEZ");
NSTimeZone.DefaultTimeZone = NSTimeZone.FromName (NSTimeZone.DefaultTimeZone.Name);
DumpTZ (NSTimeZone.SystemTimeZone, "SystemTimeZone");
DumpTZ (NSTimeZone.DefaultTimeZone, "DefaultTimeZone");
DumpTZ (NSTimeZone.LocalTimeZone, "LocalTimeZone");
DumpTZ (NSTimeZone.FromName ("Europe/Berlin"), "Europe/Berlin");
}
static int counter;
static void DumpTZ (NSTimeZone tz, string name)
{
var now = NSDate.Now;
Console.WriteLine ("#{2} ({3}): {0}: 0x{1}", tz, tz == null ? "0" : tz.Handle.ToString ("x"), ++counter, name);
if (tz != null) {
Console.WriteLine (" Abbreviation: {0}", tz.Abbreviation ());
Console.WriteLine (" Data: {0}", tz.Data == null ? "null" : "not null");
Console.WriteLine (" Data.Length: {0}", tz.Data != null ? tz.Data.Length.ToString () : "N/A");
Console.WriteLine (" Name: {0}", tz.Name);
Console.WriteLine (" DaylightSavingTimeOffset ({0}): {1}", now, tz.DaylightSavingTimeOffset (now));
Console.WriteLine (" GetSecondsFromGMT: {0}", tz.GetSecondsFromGMT);
Console.WriteLine (" IsDaylightSavingsTime ({0}): {1}", now, tz.IsDaylightSavingsTime (now));
Console.WriteLine (" NextDaylightSavingTimeTransitionafter ({0}): {1}", now, tz.NextDaylightSavingTimeTransitionAfter (now));
Console.WriteLine (" SecondsFromGMT ({0}): {1}", now, tz.SecondsFromGMT (now));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment