public void testSIF2xDateTimeParsing() { SifFormatter formatter = new Sif2xFormatter(); String testValue = formatter.ToDateTimeString(null); Assert.IsNull(testValue, "Date value should be null" ); DateTime assertedDate = new DateTime(1999, 9, 1, 22, 2, 4 ); TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(assertedDate); Console.Write( "UTC Offset: "); Console.WriteLine( utcOffset ); Console.WriteLine(); Nullable<DateTime> assertedDateTime = new Nullable<DateTime>(assertedDate); String sifString = formatter.ToDateTimeString(assertedDateTime); AssertDateTimeParsing(assertedDateTime, formatter, sifString, "Re-Parse of original"); String test1 = "1999-09-01T22:02:04"; AssertDateTimeParsing(assertedDateTime, formatter, test1, "Date Time"); DateTime UTcTime = assertedDate.ToUniversalTime(); String test2 = UTcTime.ToString("s") + "Z"; AssertDateTimeParsing(assertedDateTime, formatter, test2, "UTC Time (Z)"); // test2 = UTcTime.ToString("s") + "+0:00"; // AssertDateTimeParsing(assertedDateTime, formatter, test2, "UTC Time (+00:00)"); // Test the time, using Eastern time DateTime easternTime = UTcTime.AddHours(-5); String test3 = easternTime.ToString("s") + "-05:00"; AssertDateTimeParsing(assertedDateTime, formatter, test3, "Eastern Time"); // Test the time, using european time DateTime europeanTime = UTcTime.AddHours( 3 ); String test4 = europeanTime.ToString( "s" ) + "+03:00"; AssertDateTimeParsing(assertedDateTime, formatter, test4, "European Time"); }
public void testSIF2xTimeParsing() { SifFormatter formatter = new Sif2xFormatter(); String testValue = formatter.ToTimeString(null); Assert.IsNull(testValue, "Date value should be null" ); DateTime now = DateTime.Now; DateTime assertedDate = new DateTime( now.Year, now.Month, now.Day, 21, 0, 59); Nullable<DateTime> assertedDateTime = new Nullable<DateTime>(assertedDate); String sifString = formatter.ToDateTimeString(assertedDateTime); AssertTimeParsing(assertedDateTime, formatter, sifString, "Re-Parse of original"); String test1 = "21:00:59"; AssertTimeParsing(assertedDateTime, formatter, test1, "Date Time"); DateTime UTcTime = assertedDate.ToUniversalTime(); String test2 = UTcTime.ToString("HH:mm:ss") + "Z"; AssertTimeParsing(assertedDateTime, formatter, test2, "UTC Time (Z)"); // test2 = UTcTime.ToString("HH:mm:ss") + "+0:00"; // AssertTimeParsing(assertedDateTime, formatter, test2, "UTC Time (+00:00)"); // Test the time, using Eastern time DateTime easternTime = UTcTime.AddHours(-5); String test3 = easternTime.ToString("HH:mm:ss") + "-05:00"; AssertTimeParsing(assertedDateTime, formatter, test3, "Eastern Time"); // Test the time, using european time DateTime europeanTime = UTcTime.AddHours(3); String test4 = europeanTime.ToString("HH:mm:s.s") + "+03:00"; AssertTimeParsing(assertedDateTime, formatter, test4, "European Time"); test4 = "2008-04-21T14:16:00.3651098Z"; DateTime t = formatter.ToDateTime( test4 ).Value; Console.WriteLine( t ); }