|
|
|
@ -32,7 +32,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
using(_currentTimezoneProvider.Change("Europe/Istanbul")) |
|
|
|
{ |
|
|
|
var dateTime = new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Utc); |
|
|
|
var convertedDateTime = _clock.ConvertTo(dateTime); |
|
|
|
var convertedDateTime = _clock.ConvertToUserTime(dateTime); |
|
|
|
convertedDateTime.Kind.ShouldBe(DateTimeKind.Unspecified); |
|
|
|
convertedDateTime.ToString("O").ShouldBe("2025-03-01T08:30:00.0000000"); //Without Z
|
|
|
|
} |
|
|
|
@ -41,7 +41,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
{ |
|
|
|
// ConvertTo will not convert the DateTimeKind.Local
|
|
|
|
var dateTime = new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Local); |
|
|
|
var convertedDateTime = _clock.ConvertTo(dateTime); |
|
|
|
var convertedDateTime = _clock.ConvertToUserTime(dateTime); |
|
|
|
convertedDateTime.Kind.ShouldBe(DateTimeKind.Local); |
|
|
|
convertedDateTime.ToString("O").ShouldBe(dateTime.ToString("O")); |
|
|
|
} |
|
|
|
@ -50,7 +50,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
{ |
|
|
|
// ConvertTo will not convert if the timezone is not set
|
|
|
|
var dateTime = new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Local); |
|
|
|
var convertedDateTime = _clock.ConvertTo(dateTime); |
|
|
|
var convertedDateTime = _clock.ConvertToUserTime(dateTime); |
|
|
|
convertedDateTime.Kind.ShouldBe(DateTimeKind.Local); |
|
|
|
convertedDateTime.ToString("O").ShouldBe(dateTime.ToString("O")); |
|
|
|
} |
|
|
|
@ -62,7 +62,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
using(_currentTimezoneProvider.Change("Europe/Istanbul")) |
|
|
|
{ |
|
|
|
var dateTimeOffset = new DateTimeOffset(new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Utc), TimeSpan.Zero); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertTo(dateTimeOffset); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertToUserTime(dateTimeOffset); |
|
|
|
convertedDateTimeOffset.Offset.ShouldBe(TimeSpan.FromHours(3)); |
|
|
|
convertedDateTimeOffset.ToString("O").ShouldBe("2025-03-01T08:30:00.0000000+03:00"); |
|
|
|
} |
|
|
|
@ -70,7 +70,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
using(_currentTimezoneProvider.Change("Europe/Istanbul")) |
|
|
|
{ |
|
|
|
var dateTimeOffset = new DateTimeOffset(new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Unspecified), TimeSpan.Zero); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertTo(dateTimeOffset); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertToUserTime(dateTimeOffset); |
|
|
|
convertedDateTimeOffset.Offset.ShouldBe(TimeSpan.FromHours(3)); |
|
|
|
convertedDateTimeOffset.ToString("O").ShouldBe("2025-03-01T08:30:00.0000000+03:00"); |
|
|
|
} |
|
|
|
@ -78,7 +78,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
using(_currentTimezoneProvider.Change("Europe/Istanbul")) |
|
|
|
{ |
|
|
|
var dateTimeOffset = new DateTimeOffset(new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Unspecified), TimeSpan.FromHours(3)); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertTo(dateTimeOffset); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertToUserTime(dateTimeOffset); |
|
|
|
convertedDateTimeOffset.Offset.ShouldBe(TimeSpan.FromHours(3)); |
|
|
|
convertedDateTimeOffset.ShouldBe(dateTimeOffset); |
|
|
|
} |
|
|
|
@ -86,7 +86,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
using(_currentTimezoneProvider.Change("Europe/Istanbul")) |
|
|
|
{ |
|
|
|
var dateTimeOffset = new DateTimeOffset(new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Unspecified), TimeSpan.FromHours(8)); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertTo(dateTimeOffset); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertToUserTime(dateTimeOffset); |
|
|
|
convertedDateTimeOffset.Offset.ShouldBe(TimeSpan.FromHours(3)); |
|
|
|
convertedDateTimeOffset.DateTime.ShouldBe(new DateTime(2025, 3, 1, 0, 30, 0, DateTimeKind.Unspecified)); |
|
|
|
} |
|
|
|
@ -95,7 +95,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
{ |
|
|
|
// ConvertTo will not convert if the timezone is not set
|
|
|
|
var dateTimeOffset = new DateTimeOffset(new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Unspecified), TimeSpan.FromHours(8)); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertTo(dateTimeOffset); |
|
|
|
var convertedDateTimeOffset = _clock.ConvertToUserTime(dateTimeOffset); |
|
|
|
convertedDateTimeOffset.Offset.ShouldBe(TimeSpan.FromHours(8)); |
|
|
|
convertedDateTimeOffset.ShouldBe(dateTimeOffset); |
|
|
|
} |
|
|
|
@ -107,7 +107,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
using(_currentTimezoneProvider.Change("Europe/Istanbul")) |
|
|
|
{ |
|
|
|
var dateTime = new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Unspecified); |
|
|
|
var convertedDateTime = _clock.ConvertFrom(dateTime); |
|
|
|
var convertedDateTime = _clock.ConvertToUtc(dateTime); |
|
|
|
convertedDateTime.Kind.ShouldBe(DateTimeKind.Utc); |
|
|
|
convertedDateTime.ToString("O").ShouldBe("2025-03-01T02:30:00.0000000Z"); |
|
|
|
} |
|
|
|
@ -115,7 +115,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
using(_currentTimezoneProvider.Change("Europe/Istanbul")) |
|
|
|
{ |
|
|
|
var dateTime = new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Local); |
|
|
|
var convertedDateTime = _clock.ConvertFrom(dateTime); |
|
|
|
var convertedDateTime = _clock.ConvertToUtc(dateTime); |
|
|
|
convertedDateTime.Kind.ShouldBe(DateTimeKind.Utc); |
|
|
|
convertedDateTime.ToString("O").ShouldBe("2025-03-01T02:30:00.0000000Z"); |
|
|
|
} |
|
|
|
@ -123,7 +123,7 @@ public class Clock_Utc_Tests : AbpIntegratedTest<AbpTimingTestModule> |
|
|
|
using(_currentTimezoneProvider.Change("Europe/Istanbul")) |
|
|
|
{ |
|
|
|
var dateTime = new DateTime(2025, 3, 1, 5, 30, 0, DateTimeKind.Utc); |
|
|
|
var convertedDateTime = _clock.ConvertFrom(dateTime); |
|
|
|
var convertedDateTime = _clock.ConvertToUtc(dateTime); |
|
|
|
convertedDateTime.Kind.ShouldBe(DateTimeKind.Utc); |
|
|
|
convertedDateTime.ToString("O").ShouldBe("2025-03-01T05:30:00.0000000Z"); |
|
|
|
} |
|
|
|
|