public static DateTimeOffset GetCorrectedDate(this DATETIMETYPE date, TimeZoneInfo quickBooksTimeZone) { var dateTime = date.ToDateTime(); var correctedOffset = quickBooksTimeZone.GetUtcOffset(dateTime); return(new DateTimeOffset(dateTime, correctedOffset)); }
public void ToDateTimeEqualsInputWhenConstructedFromLocalDateTime() { var input = new DateTime(2018, 8, 1, 0, 0, 0, DateTimeKind.Local); var dt = new DATETIMETYPE(input); var output = dt.ToDateTime(); Assert.AreEqual(input, output); }
public void DateTimeWithDSTIsNotHandledByQuickBooks() { // This should read 2015-04-03T10:06:17-07:00 // But QuickBooks does not handle DST. So we need to handle it ourself. var dt = new DATETIMETYPE("2015-04-03T10:06:17-08:00", QuickBooksTestHelper.GetPacificStandardTimeZoneInfo()); Assert.AreEqual(17, dt.ToDateTime().ToUniversalTime().Hour); }
public void DateTimeWithDSTIsNotHandledByQuickBooks() { // This should read 2015-04-03T10:06:17-07:00 // But QuickBooks does not handle DST. So we need to handle it ourself. var dt = new DATETIMETYPE("2015-04-03T10:06:17-08:00", QuickBooksTestHelper.GetPacificStandardTimeZoneInfo()); Assert.AreEqual(17, dt.ToDateTime().ToUniversalTime().Hour); }
public void ToDateTimeIsLocalKindWhenConstructedFromLocalDateTime() { // This situation only covers when a consumer of this library is converting back to DateTime after initializing from DateTime // No QuickBooks parsed DATETIMETYPE will ever have a Local kind var dt = new DATETIMETYPE(new DateTime(2019, 1, 1, 8, 0, 0, 0, DateTimeKind.Local)); Assert.AreEqual(DateTimeKind.Local, dt.ToDateTime().Kind); }
public void ToDateTimeIsUnspecifiedForNonZeroAndEmptyOffsets(DATETIMETYPE input) { Assert.AreEqual(DateTimeKind.Unspecified, input.ToDateTime().Kind); }
public void ToDateTimeIsUtcForZeroOffsets(DATETIMETYPE input) { Assert.AreEqual(DateTimeKind.Utc, input.ToDateTime().Kind); }
public void DateTimeWithNoDSTIsNotHandledByQuickBooks() { var dt = new DATETIMETYPE("2015-03-01T10:06:17-08:00", QuickBooksTestHelper.GetPacificStandardTimeZoneInfo()); Assert.AreEqual(18, dt.ToDateTime().ToUniversalTime().Hour); }
public void DateTimeWithDSTNothingHappensWhenNoTimzoneSupplied() { var dt = new DATETIMETYPE("2015-04-03T10:06:17-08:00"); Assert.AreEqual(18, dt.ToDateTime().ToUniversalTime().Hour); }
public void DateTimeInvalidSentByQuickBooks() { var dt = new DATETIMETYPE("0000-00-00", QuickBooksTestHelper.GetPacificStandardTimeZoneInfo()); Assert.AreEqual(DateTime.MinValue, dt.ToDateTime()); }
public void DateTimeWithNoDSTIsNotHandledByQuickBooks() { var dt = new DATETIMETYPE("2015-03-01T10:06:17-08:00", QuickBooksTestHelper.GetPacificStandardTimeZoneInfo()); Assert.AreEqual(18, dt.ToDateTime().ToUniversalTime().Hour); }
public void DateTimeWithDSTNothingHappensWhenNoTimzoneSupplied() { var dt = new DATETIMETYPE("2015-04-03T10:06:17-08:00"); Assert.AreEqual(18, dt.ToDateTime().ToUniversalTime().Hour); }
public void DateTimeInvalidSentByQuickBooks() { var dt = new DATETIMETYPE("0000-00-00", QuickBooksTestHelper.GetPacificStandardTimeZoneInfo()); Assert.AreEqual(DateTime.MinValue, dt.ToDateTime()); }