diff --git a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String.csproj b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String.csproj
index 40c60dd4c8..7de2e17cda 100644
--- a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String.csproj
+++ b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String.csproj
@@ -2,7 +2,7 @@
Exe
- net6.0
+ net11.0
enable
enable
diff --git a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/DateTimeExtensions.cs b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/DateTimeExtensions.cs
index 533a2dd57a..4da7169a08 100644
--- a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/DateTimeExtensions.cs
+++ b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/DateTimeExtensions.cs
@@ -1,40 +1,38 @@
using System.Globalization;
-using System.Text.RegularExpressions;
-namespace ConvertDateTimeToIso8601String
+namespace ConvertDateTimeToIso8601String;
+
+public static class DateTimeExtensions
{
- public static class DateTimeExtensions
+ public static string ToUniversalIso8601(this DateTime dateTime)
+ {
+ return dateTime.ToUniversalTime().ToString("u").Replace(" ", "T");
+ }
+
+ public static string ToShortIso8601WeekDateString(this DateTime dateTime, bool useSeparator = true)
+ {
+ var separator = useSeparator ? "-" : string.Empty;
+
+ var weekYear = ISOWeek.GetYear(dateTime);
+ var weekOfYear = ISOWeek.GetWeekOfYear(dateTime);
+ var weekPlaceHolder = $"{weekOfYear}".PadLeft(2, '0');
+
+ return $"{weekYear}{separator}W{weekPlaceHolder}";
+ }
+
+ public static string ToExtendedIso8601WeekDateString(this DateTime dateTime, bool useSeparator = true)
{
- public static string ToUniversalIso8601(this DateTime dateTime)
- {
- return dateTime.ToUniversalTime().ToString("u").Replace(" ", "T");
- }
-
- public static string ToShortIso8601WeekDateString(this DateTime dateTime, bool useSeparator = true)
- {
- var separator = useSeparator ? "-" : string.Empty;
- var culture = CultureInfo.InvariantCulture;
- var format = culture.DateTimeFormat;
-
- var weekOfYear = culture.Calendar.GetWeekOfYear(dateTime, format.CalendarWeekRule, format.FirstDayOfWeek);
- var weekPlaceHolder = $"{weekOfYear}".PadLeft(2, '0');
-
- return $"{dateTime.Year}{separator}W{weekPlaceHolder}";
- }
-
- public static string ToExtendedIso8601WeekDateString(this DateTime dateTime, bool useSeparator = true)
- {
- var separator = useSeparator ? "-" : string.Empty;
-
- return $"{dateTime.ToShortIso8601WeekDateString(useSeparator)}{separator}{(int)dateTime.DayOfWeek}";
- }
-
- public static string ToIso8601OrdinalDateString(this DateTime dateTime, bool useSeparator = true)
- {
- var separator = useSeparator ? "-" : string.Empty;
- var dayPlaceHolder = $"{dateTime.DayOfYear}".PadLeft(3, '0');
-
- return $"{dateTime.Year}{separator}{dayPlaceHolder}";
- }
+ var separator = useSeparator ? "-" : string.Empty;
+ var dayOfWeek = dateTime.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)dateTime.DayOfWeek;
+
+ return $"{dateTime.ToShortIso8601WeekDateString(useSeparator)}{separator}{dayOfWeek}";
+ }
+
+ public static string ToIso8601OrdinalDateString(this DateTime dateTime, bool useSeparator = true)
+ {
+ var separator = useSeparator ? "-" : string.Empty;
+ var dayPlaceHolder = $"{dateTime.DayOfYear}".PadLeft(3, '0');
+
+ return $"{dateTime.Year}{separator}{dayPlaceHolder}";
}
-}
\ No newline at end of file
+}
diff --git a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/Program.cs b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/Program.cs
index 7a9816c10b..ff22a723d2 100644
--- a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/Program.cs
+++ b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/Program.cs
@@ -1,5 +1,7 @@
+using System.Globalization;
using ConvertDateTimeToIso8601String;
+// The comments show the output on a machine whose time zone is UTC+06:00.
var localTime = new DateTime(2022, 1, 13, 16, 25, 35, 125, DateTimeKind.Local);
var utcTime = new DateTime(2022, 1, 13, 16, 25, 35, 125, DateTimeKind.Utc);
@@ -11,12 +13,29 @@
Console.WriteLine($"Local: {localTime.ToString("o")}"); // 2022-01-13T16:25:35.1250000+06:00
Console.WriteLine($"UTC: {utcTime.ToString("o")}"); // 2022-01-13T16:25:35.1250000Z
+// Round-trip format with a DateTimeOffset
+var offsetTime = new DateTimeOffset(2022, 1, 13, 16, 25, 35, 125, TimeSpan.FromHours(6));
+
+Console.WriteLine(offsetTime.ToString("o")); // 2022-01-13T16:25:35.1250000+06:00
+Console.WriteLine(offsetTime.ToUniversalTime().ToString("o")); // 2022-01-13T10:25:35.1250000+00:00
+
// Universal datetime format specifier
Console.WriteLine($"Local: {localTime.ToUniversalIso8601()}"); // 2022-01-13T10:25:35Z
Console.WriteLine($"UTC: {utcTime.ToUniversalIso8601()}"); // 2022-01-13T16:25:35Z
// Basic syntax for custom formats
-var output = localTime.ToString("yyyy-MM-ddTHH:mm:ssK");
+var output = localTime.ToString("yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture);
+
+// Custom formats follow the current culture unless we pass one
+CultureInfo.CurrentCulture = new CultureInfo("fi-FI");
+Console.WriteLine(localTime.ToString("yyyy-MM-ddTHH:mm:ssK")); // 2022-01-13T16.25.35+06:00
+Console.WriteLine(localTime.ToString("yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture)); // 2022-01-13T16:25:35+06:00
+
+CultureInfo.CurrentCulture = new CultureInfo("th-TH");
+Console.WriteLine(localTime.ToString("yyyy-MM-dd")); // 2565-01-13
+Console.WriteLine(localTime.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); // 2022-01-13
+
+CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
// ISO 8601 compliant custom formats
var customFormats = new[]
@@ -24,40 +43,47 @@
"yyyy-MM-dd",
"yyyyMMdd",
"yyyy-MM",
- "--MM-dd",
- "--MMdd",
"THH:mm:ss.fff",
"THH:mm:ss",
"THH:mm",
"THH",
- "THHmmssfff",
- "yyyyMMddTHHmmssK",
+ "THHmmss.fff",
+ "yyyy-MM-ddTHH:mm:ssK",
"yyyyMMddTHHmm",
- "yyyy-MM-ddTHH:mmZ",
- "yyyyMMddTHHmmsszzz",
+ "yyyy-MM-ddTHH:mm:sszzz",
"yyyyMMddTHHmmsszz",
};
-customFormats.ToList().ForEach(f => Console.WriteLine($"{f} \t {localTime.ToString(f)}"));
+foreach (var customFormat in customFormats)
+{
+ Console.WriteLine($"{customFormat} \t {localTime.ToString(customFormat, CultureInfo.InvariantCulture)}");
+}
+
+// 'Z' is a literal, so it belongs on UTC values only
+Console.WriteLine(utcTime.ToString("yyyy-MM-ddTHH:mmZ", CultureInfo.InvariantCulture)); // 2022-01-13T16:25Z
var format = "yyyy-MM-ddTHH:mm:ssK";
var unspecified = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Unspecified);
var utc = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Utc);
var local = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Local);
-Console.WriteLine(unspecified.ToString(format)); // 2022-01-13T16:25:30
-Console.WriteLine(utc.ToString(format)); // 2022-01-13T16:25:30Z
-Console.WriteLine(local.ToString(format)); // 2022-01-13T16:25:30+06:00
-Console.WriteLine(local.ToString("yyyy-MM-ddTHH:mm:sszz")); // 2022-01-13T16:25:30+06
+Console.WriteLine(unspecified.ToString(format, CultureInfo.InvariantCulture)); // 2022-01-13T16:25:30
+Console.WriteLine(utc.ToString(format, CultureInfo.InvariantCulture)); // 2022-01-13T16:25:30Z
+Console.WriteLine(local.ToString(format, CultureInfo.InvariantCulture)); // 2022-01-13T16:25:30+06:00
+Console.WriteLine(local.ToString("yyyy-MM-ddTHH:mm:sszz", CultureInfo.InvariantCulture)); // 2022-01-13T16:25:30+06
// Week dates - short form
-Console.WriteLine(localTime.ToShortIso8601WeekDateString()); // 2022-W03
-Console.WriteLine(localTime.ToShortIso8601WeekDateString(useSeparator: false)); // 2022W03
+Console.WriteLine(localTime.ToShortIso8601WeekDateString()); // 2022-W02
+Console.WriteLine(localTime.ToShortIso8601WeekDateString(useSeparator: false)); // 2022W02
// Week dates - extended form
-Console.WriteLine(localTime.ToExtendedIso8601WeekDateString()); // 2022-W03-4
-Console.WriteLine(localTime.ToExtendedIso8601WeekDateString(useSeparator: false)); // 2022W034
+Console.WriteLine(localTime.ToExtendedIso8601WeekDateString()); // 2022-W02-4
+Console.WriteLine(localTime.ToExtendedIso8601WeekDateString(useSeparator: false)); // 2022W024
+
+// Week dates near the turn of the year
+Console.WriteLine(new DateTime(2021, 1, 1).ToExtendedIso8601WeekDateString()); // 2020-W53-5
+Console.WriteLine(new DateTime(2022, 1, 2).ToExtendedIso8601WeekDateString()); // 2021-W52-7
// Ordinal dates
Console.WriteLine(localTime.ToIso8601OrdinalDateString()); // 2022-013
-Console.WriteLine(localTime.ToIso8601OrdinalDateString(useSeparator: false)); // 2022013
\ No newline at end of file
+Console.WriteLine(localTime.ToIso8601OrdinalDateString(useSeparator: false)); // 2022013
diff --git a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601StringTests/ConvertDateTimeToIso8601StringTests.cs b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601StringTests/ConvertDateTimeToIso8601StringTests.cs
index 7271ea27be..449ece2e67 100644
--- a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601StringTests/ConvertDateTimeToIso8601StringTests.cs
+++ b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601StringTests/ConvertDateTimeToIso8601StringTests.cs
@@ -1,110 +1,144 @@
+using System.Globalization;
using ConvertDateTimeToIso8601String;
-using ReflectionMagic;
-using System;
-using System.IO;
using Xunit;
-namespace ConvertDateTimeToIso8601StringTests
+namespace ConvertDateTimeToIso8601StringTests;
+
+public class ConvertDateTimeToIso8601StringUnitTest
{
- public class ConvertDateTimeToIso8601StringUnitTest : IDisposable
+ private readonly DateTime _localTime = new(2022, 1, 13, 16, 25, 35, 125, DateTimeKind.Local);
+ private readonly DateTime _utcTime = new(2022, 1, 13, 16, 25, 35, 125, DateTimeKind.Utc);
+
+ // Local values print the offset of the machine that runs the tests, so the expected text is built from it.
+ private static string LocalOffset(DateTime local)
{
- readonly DateTime localTime = new DateTime(2022, 1, 13, 16, 25, 35, 125, DateTimeKind.Local);
- readonly DateTime utcTime = new DateTime(2022, 1, 13, 16, 25, 35, 125, DateTimeKind.Utc);
+ var offset = TimeZoneInfo.Local.GetUtcOffset(local);
+ var sign = offset < TimeSpan.Zero ? "-" : "+";
- private readonly TimeZoneInfo _originalLocalTimeZone;
+ return $"{sign}{offset.Duration():hh\\:mm}";
+ }
- public ConvertDateTimeToIso8601StringUnitTest()
- {
- // Mock local TimeZone
- _originalLocalTimeZone = TimeZoneInfo.Local;
- SetLocalTimeZone(TimeZoneInfo.FindSystemTimeZoneById("Central Asia Standard Time"));
- }
+ [Fact]
+ public void GivenADateTime_WhenConvertedBySortableFormat_ThenVerifyIso8601Output()
+ {
+ Assert.Equal("2022-01-13T16:25:35", _localTime.ToString("s"));
+ Assert.Equal("2022-01-13T16:25:35", _utcTime.ToString("s"));
+ }
- [Fact]
- public void GivenADateTime_WhenConvertedBySortableFormat_ThenVerifyIso8601Output()
- {
- Assert.Equal("2022-01-13T16:25:35", localTime.ToString("s"));
+ [Fact]
+ public void GivenADateTime_WhenConvertedByRoundTripFormat_ThenVerifyIso8601Output()
+ {
+ Assert.Equal($"2022-01-13T16:25:35.1250000{LocalOffset(_localTime)}", _localTime.ToString("o"));
+ Assert.Equal("2022-01-13T16:25:35.1250000Z", _utcTime.ToString("o"));
+ }
- Assert.Equal("2022-01-13T16:25:35", utcTime.ToString("s"));
- }
+ [Fact]
+ public void GivenADateTimeOffset_WhenConvertedByRoundTripFormat_ThenVerifyIso8601Output()
+ {
+ var offsetTime = new DateTimeOffset(2022, 1, 13, 16, 25, 35, 125, TimeSpan.FromHours(6));
- [Fact]
- public void GivenADateTime_WhenConvertedByRoundTripFormat_ThenVerifyIso8601Output()
- {
- Assert.Equal("2022-01-13T16:25:35.1250000+06:00", localTime.ToString("o"));
+ Assert.Equal("2022-01-13T16:25:35.1250000+06:00", offsetTime.ToString("o"));
+ Assert.Equal("2022-01-13T10:25:35.1250000+00:00", offsetTime.ToUniversalTime().ToString("o"));
+ }
- Assert.Equal("2022-01-13T16:25:35.1250000Z", utcTime.ToString("o"));
- }
+ [Fact]
+ public void GivenADateTime_WhenConvertedByToUniversalIso8601String_ThenVerifyIso8601Output()
+ {
+ var expectedLocal = new DateTime(2022, 1, 13, 16, 25, 35, DateTimeKind.Utc)
+ - TimeZoneInfo.Local.GetUtcOffset(_localTime);
- [Fact]
- public void GivenADateTime_WhenConvertedByToUniversalIso8601String_ThenVerifyIso8601Output()
- {
- Assert.Equal("2022-01-13T10:25:35Z", localTime.ToUniversalIso8601());
+ Assert.Equal($"{expectedLocal:yyyy'-'MM'-'dd'T'HH':'mm':'ss}Z", _localTime.ToUniversalIso8601());
+ Assert.Equal("2022-01-13T16:25:35Z", _utcTime.ToUniversalIso8601());
+ }
- Assert.Equal("2022-01-13T16:25:35Z", utcTime.ToUniversalIso8601());
- }
+ [Theory]
+ [InlineData("yyyy-MM-dd", "2022-01-13")]
+ [InlineData("yyyyMMdd", "20220113")]
+ [InlineData("yyyy-MM", "2022-01")]
+ [InlineData("THH:mm:ss.fff", "T16:25:35.125")]
+ [InlineData("THH:mm:ss", "T16:25:35")]
+ [InlineData("THH:mm", "T16:25")]
+ [InlineData("THH", "T16")]
+ [InlineData("THHmmss.fff", "T162535.125")]
+ [InlineData("yyyyMMddTHHmm", "20220113T1625")]
+ public void GivenADateTime_WhenConvertedByCustomFormats_ThenVerifyIso8601Output(string format, string expectedOutput)
+ {
+ Assert.Equal(expectedOutput, _localTime.ToString(format, CultureInfo.InvariantCulture));
+ }
- [Theory]
- [InlineData("yyyy-MM-dd", "2022-01-13")]
- [InlineData("yyyyMMdd", "20220113")]
- [InlineData("yyyy-MM", "2022-01")]
- [InlineData("--MM-dd", "--01-13")]
- [InlineData("--MMdd", "--0113")]
- [InlineData("THH:mm:ss.fff", "T16:25:35.125")]
- [InlineData("THH:mm:ss", "T16:25:35")]
- [InlineData("THH:mm", "T16:25")]
- [InlineData("THH", "T16")]
- [InlineData("THHmmssfff", "T162535125")]
- [InlineData("yyyyMMddTHHmmssK", "20220113T162535+06:00")]
- [InlineData("yyyyMMddTHHmm", "20220113T1625")]
- [InlineData("yyyy-MM-ddTHH:mmZ", "2022-01-13T16:25Z")]
- [InlineData("yyyyMMddTHHmmsszzz", "20220113T162535+06:00")]
- [InlineData("yyyyMMddTHHmmsszz", "20220113T162535+06")]
- public void GivenADateTime_WhenConvertedByCustomFormats_ThenVerifyIso8601Output(string format, string expectedOutput)
- {
- Assert.Equal(expectedOutput, localTime.ToString(format));
- }
+ [Fact]
+ public void GivenALocalDateTime_WhenConvertedByCustomFormatsWithOffset_ThenVerifyIso8601Output()
+ {
+ var offset = LocalOffset(_localTime);
- [Fact]
- public void GivenADateTime_WhenConvertedByTimeZoneLiteral_ThenVerifyIso8601Output()
- {
- var format = "yyyy-MM-ddTHH:mm:ssK";
- var unspecified = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Unspecified);
- var utc = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Utc);
- var local = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Local);
-
- Assert.Equal("2022-01-13T16:25:30", unspecified.ToString(format));
- Assert.Equal("2022-01-13T16:25:30Z", utc.ToString(format));
- Assert.Equal("2022-01-13T16:25:30+06:00", local.ToString(format));
- Assert.Equal("2022-01-13T16:25:30+06", local.ToString("yyyy-MM-ddTHH:mm:sszz"));
- }
+ Assert.Equal($"2022-01-13T16:25:35{offset}", _localTime.ToString("yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture));
+ Assert.Equal($"2022-01-13T16:25:35{offset}", _localTime.ToString("yyyy-MM-ddTHH:mm:sszzz", CultureInfo.InvariantCulture));
+ Assert.Equal($"20220113T162535{offset[..3]}", _localTime.ToString("yyyyMMddTHHmmsszz", CultureInfo.InvariantCulture));
+ }
- [Fact]
- public void GivenADateTime_WhenConvertedByToIso8601WeekDateString_ThenVerifyIso8601Output()
- {
- Assert.Equal("2022-W03", localTime.ToShortIso8601WeekDateString());
- Assert.Equal("2022W03", localTime.ToShortIso8601WeekDateString(useSeparator: false));
+ [Fact]
+ public void GivenAUtcDateTime_WhenFormattedWithZLiteral_ThenVerifyIso8601Output()
+ {
+ Assert.Equal("2022-01-13T16:25Z", _utcTime.ToString("yyyy-MM-ddTHH:mmZ", CultureInfo.InvariantCulture));
+ }
- Assert.Equal("2022-W03-4", localTime.ToExtendedIso8601WeekDateString());
- Assert.Equal("2022W034", localTime.ToExtendedIso8601WeekDateString(useSeparator: false));
- }
+ [Fact]
+ public void GivenADateTime_WhenConvertedByTimeZoneLiteral_ThenVerifyIso8601Output()
+ {
+ var format = "yyyy-MM-ddTHH:mm:ssK";
+ var unspecified = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Unspecified);
+ var utc = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Utc);
+ var local = new DateTime(2022, 1, 13, 16, 25, 30, DateTimeKind.Local);
+ var offset = LocalOffset(local);
+
+ Assert.Equal("2022-01-13T16:25:30", unspecified.ToString(format, CultureInfo.InvariantCulture));
+ Assert.Equal("2022-01-13T16:25:30Z", utc.ToString(format, CultureInfo.InvariantCulture));
+ Assert.Equal($"2022-01-13T16:25:30{offset}", local.ToString(format, CultureInfo.InvariantCulture));
+ Assert.Equal($"2022-01-13T16:25:30{offset[..3]}", local.ToString("yyyy-MM-ddTHH:mm:sszz", CultureInfo.InvariantCulture));
+ }
- [Fact]
- public void GivenADateTime_WhenConvertedByToIso8601OrdinalDateString_ThenVerifyIso8601Output()
+ [Theory]
+ [InlineData("fi-FI")]
+ [InlineData("th-TH")]
+ public void GivenANonInvariantCulture_WhenFormattedWithInvariantCulture_ThenVerifyIso8601Output(string cultureName)
+ {
+ var original = CultureInfo.CurrentCulture;
+ try
{
- Assert.Equal("2022-013", localTime.ToIso8601OrdinalDateString());
- Assert.Equal("2022013", localTime.ToIso8601OrdinalDateString(useSeparator: false));
- }
+ CultureInfo.CurrentCulture = new CultureInfo(cultureName);
- private static void SetLocalTimeZone(TimeZoneInfo timeZoneInfo)
- {
- typeof(TimeZoneInfo).AsDynamicType().s_cachedData._localTimeZone = timeZoneInfo;
+ Assert.Equal("2022-01-13T16:25:35", _utcTime.ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
+ Assert.NotEqual("2022-01-13T16:25:35", _utcTime.ToString("yyyy-MM-ddTHH:mm:ss"));
}
-
- public void Dispose()
+ finally
{
- SetLocalTimeZone(_originalLocalTimeZone);
- GC.SuppressFinalize(this);
+ CultureInfo.CurrentCulture = original;
}
}
-}
\ No newline at end of file
+
+ [Fact]
+ public void GivenADateTime_WhenConvertedByToIso8601WeekDateString_ThenVerifyIso8601Output()
+ {
+ Assert.Equal("2022-W02", _localTime.ToShortIso8601WeekDateString());
+ Assert.Equal("2022W02", _localTime.ToShortIso8601WeekDateString(useSeparator: false));
+
+ Assert.Equal("2022-W02-4", _localTime.ToExtendedIso8601WeekDateString());
+ Assert.Equal("2022W024", _localTime.ToExtendedIso8601WeekDateString(useSeparator: false));
+ }
+
+ [Theory]
+ [InlineData(2021, 1, 1, "2020-W53-5")]
+ [InlineData(2022, 1, 2, "2021-W52-7")]
+ [InlineData(2024, 12, 30, "2025-W01-1")]
+ public void GivenADateNearTheTurnOfTheYear_WhenConvertedToWeekDate_ThenUseTheIsoWeekYear(int year, int month, int day, string expected)
+ {
+ Assert.Equal(expected, new DateTime(year, month, day).ToExtendedIso8601WeekDateString());
+ }
+
+ [Fact]
+ public void GivenADateTime_WhenConvertedByToIso8601OrdinalDateString_ThenVerifyIso8601Output()
+ {
+ Assert.Equal("2022-013", _localTime.ToIso8601OrdinalDateString());
+ Assert.Equal("2022013", _localTime.ToIso8601OrdinalDateString(useSeparator: false));
+ }
+}
diff --git a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601StringTests/ConvertDateTimeToIso8601StringTests.csproj b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601StringTests/ConvertDateTimeToIso8601StringTests.csproj
index f7b12709a6..5fe179c61a 100644
--- a/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601StringTests/ConvertDateTimeToIso8601StringTests.csproj
+++ b/dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601StringTests/ConvertDateTimeToIso8601StringTests.csproj
@@ -1,21 +1,21 @@
- net6.0
+ net11.0
+ enable
enable
false
-
-
-
-
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all