Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public partial class JapaneseCalendar : Calendar
return null;
}

if (dt.Year == s_calendarMinValue.Year)
{
// adjust the start date to the minimum supported date time
// date 1868/9/8 is actually Meiji 1/1/1 but the actual Gregorian date is 1868/10/23. The 1868/9/8 is used before as a Gregorian era start date
// for JapaneseCalendar but now we are ensuring using the correct 1868/10/23 stored in s_calendarMinValue.
dt = s_calendarMinValue;
}

if (dt < s_calendarMinValue)
{
// only populate the Eras that are valid JapaneseCalendar date times
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ namespace System.Globalization
/// Calendar support range:
/// Calendar Minimum Maximum
/// ========== ========== ==========
/// Gregorian 1868/09/08 9999/12/31
/// Gregorian 1868/10/23 9999/12/31
/// Japanese Meiji 01/01 Reiwa 7981/12/31
/// </remarks>
public partial class JapaneseCalendar : Calendar
{
private static readonly DateTime s_calendarMinValue = new DateTime(1868, 9, 8);
private static readonly DateTime s_calendarMinValue = new DateTime(1868, 10, 23);

public override DateTime MinSupportedDateTime => s_calendarMinValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public static IEnumerable<object[]> AddMonths_TestData()
yield return new object[] { new DateTime(2007, 1, 1), -1, new DateTime(2006, 12, 1) };

// Boundary values
yield return new object[] { new DateTime(1868, 9, 8), 1, new DateTime(1868, 10, 8) };
yield return new object[] { new DateTime(1868, 10, 8), -1, new DateTime(1868, 9, 8) };
yield return new object[] { new DateTime(1868, 10, 23), 1, new DateTime(1868, 11, 23) };
yield return new object[] { new DateTime(1868, 11, 23), -1, new DateTime(1868, 10, 23) };
yield return new object[] { new DateTime(9999, 11, 30), 1, new DateTime(9999, 12, 30) };
yield return new object[] { new DateTime(9999, 12, 30), -1, new DateTime(9999, 11, 30) };
yield return new object[] { DateTime.MaxValue, 0, DateTime.MaxValue };
yield return new object[] { new DateTime(1868, 9, 8), 0, new DateTime(1868, 9, 8) };
yield return new object[] { new DateTime(1868, 10, 23), 0, new DateTime(1868, 10, 23) };

// Day is not in the month
yield return new object[] { new DateTime(2006, 10, 31), 1, new DateTime(2006, 11, 30) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class JapaneseCalendarTests : CalendarTestBase
{
public override Calendar Calendar => new JapaneseCalendar();

public override DateTime MinSupportedDateTime => new DateTime(1868, 09, 08);
public override DateTime MinSupportedDateTime => new DateTime(1868, 10, 23);

public override bool SkipErasTest => true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ private static Stream GetIdnaTestTxt()
// some exception for Windows which released ICU 72.1.0.4 which using Unicode 15.1.

string fileName = null;
if (PlatformDetection.ICUVersion >= new Version(76, 0))
if (PlatformDetection.ICUVersion >= new Version(78, 0))
fileName = "IdnaTest_17.txt";
else if (PlatformDetection.ICUVersion >= new Version(76, 0))
fileName = "IdnaTest_16.txt";
else if (PlatformDetection.ICUVersion >= new Version(72, 1, 0, 4))
fileName = "IdnaTest_15_1.txt";
Expand Down Expand Up @@ -70,7 +72,9 @@ private static IEnumerable<IConformanceIdnaTest> ParseFile(Stream stream, Func<s

private static IConformanceIdnaTest GetConformanceIdnaTest(string line, int lineCount)
{
if (PlatformDetection.ICUVersion >= new Version(76, 0))
if (PlatformDetection.ICUVersion >= new Version(78, 0))
return new Unicode_17_0_IdnaTest(line, lineCount);
else if (PlatformDetection.ICUVersion >= new Version(76, 0))
return new Unicode_16_0_IdnaTest(line, lineCount);
else if (PlatformDetection.ICUVersion >= new Version(72, 1, 0, 4))
return new Unicode_15_1_IdnaTest(line, lineCount);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Unicode IDNA Mapping and Test Data
# Date: 2025-08-15
# © 2025 Unicode®, Inc.
# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
# For terms of use and license, see https://www.unicode.org/terms_of_use.html

This directory contains final data files for version 17.0.0 of
UTS #46, Unicode IDNA Compatibility Processing.

It also contains the data file Idna2008.txt listing the
IDNA2008_Category Property for the same version.
The listing matches the "IDNA Derived Property" as defined in RFC 5892.

https://www.unicode.org/reports/tr46/
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;
using Xunit;

namespace System.Globalization.Tests
{
/// <summary>
/// Class to read data obtained from http://www.unicode.org/Public/idna. For more information read the information
/// contained in Data\Unicode_16_0\IdnaTest_16.txt
///
/// The structure of the data set is a semicolon delimited list with the following columns:
///
/// Column 1: source - The source string to be tested
/// Column 2: toUnicode - The result of applying toUnicode to the source,
/// with Transitional_Processing=false.
/// A blank value means the same as the source value.
/// Column 3: toUnicodeStatus - A set of status codes, each corresponding to a particular test.
/// A blank value means [] (no errors).
/// Column 4: toAsciiN - The result of applying toASCII to the source,
/// with Transitional_Processing=false.
/// A blank value means the same as the toUnicode value.
/// Column 5: toAsciiNStatus - A set of status codes, each corresponding to a particular test.
/// A blank value means the same as the toUnicodeStatus value.
/// An explicit [] means no errors.
/// Column 6: toAsciiT - The result of applying toASCII to the source,
/// with Transitional_Processing=true.
/// A blank value means the same as the toAsciiN value.
/// Column 7: toAsciiTStatus - A set of status codes, each corresponding to a particular test.
/// A blank value means the same as the toAsciiNStatus value.
/// An explicit [] means no errors.
///
/// If the value of toUnicode or toAsciiN is the same as source, the column will be blank.
/// </summary>
public class Unicode_17_0_IdnaTest : Unicode_IdnaTest
{
public Unicode_17_0_IdnaTest(string line, int lineNumber)
{
var split = line.Split(';');

Type = PlatformDetection.IsNlsGlobalization ? IdnType.Transitional : IdnType.Nontransitional;

Source = EscapedToLiteralString(split[0], lineNumber);

UnicodeResult = new ConformanceIdnaUnicodeTestResult(EscapedToLiteralString(split[1], lineNumber), Source, EscapedToLiteralString(split[2], lineNumber), string.Empty, Source);
ASCIIResult = new ConformanceIdnaTestResult(EscapedToLiteralString(split[3], lineNumber), UnicodeResult.Value, EscapedToLiteralString(split[4], lineNumber), UnicodeResult.StatusValue, Source);

// NLS uses transitional IDN processing.
if (Type == IdnType.Transitional)
{
ASCIIResult = new ConformanceIdnaTestResult(EscapedToLiteralString(split[5], lineNumber), ASCIIResult.Value, EscapedToLiteralString(split[6], lineNumber), ASCIIResult.StatusValue);
}

LineNumber = lineNumber;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
Link="IdnMapping\Data\Unicode_15_1\Unicode_15_1_IdnaTest.cs" />
<Compile Include="..\IdnMapping\Data\Unicode_16_0\Unicode_16_0_IdnaTest.cs"
Link="IdnMapping\Data\Unicode_16_0\Unicode_16_0_IdnaTest.cs" />
<Compile Include="..\IdnMapping\Data\Unicode_17_0\Unicode_17_0_IdnaTest.cs"
Link="IdnMapping\Data\Unicode_17_0\Unicode_17_0_IdnaTest.cs" />
<Compile Include="..\IdnMapping\IdnMappingIdnaConformanceTests.cs"
Link="IdnMapping\IdnMappingIdnaConformanceTests.cs" />
<Compile Include="..\IdnMapping\Data\Factory.cs"
Expand Down Expand Up @@ -57,6 +59,7 @@
<EmbeddedResource Include="..\IdnMapping\Data\Unicode_15_0\IdnaTest_15_0.txt" />
<EmbeddedResource Include="..\IdnMapping\Data\Unicode_15_1\IdnaTest_15_1.txt" />
<EmbeddedResource Include="..\IdnMapping\Data\Unicode_16_0\IdnaTest_16.txt" />
<EmbeddedResource Include="..\IdnMapping\Data\Unicode_17_0\IdnaTest_17.txt" />
<EmbeddedResource Include="..\Normalization\Data\win8.txt">
<LogicalName>NormalizationDataWin8</LogicalName>
</EmbeddedResource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<Compile Include="IdnMapping\Data\Unicode_15_0\Unicode_15_0_IdnaTest.cs" />
<Compile Include="IdnMapping\Data\Unicode_15_1\Unicode_15_1_IdnaTest.cs" />
<Compile Include="IdnMapping\Data\Unicode_16_0\Unicode_16_0_IdnaTest.cs" />
<Compile Include="IdnMapping\Data\Unicode_17_0\Unicode_17_0_IdnaTest.cs" />
<Compile Include="IdnMapping\IdnMappingIdnaConformanceTests.cs" />
<Compile Include="IdnMapping\Data\Factory.cs" />
<Compile Include="IdnMapping\Data\ConformanceIdnaTestResult.cs" />
Expand All @@ -34,6 +35,7 @@
<EmbeddedResource Include="IdnMapping\Data\Unicode_15_0\IdnaTest_15_0.txt" />
<EmbeddedResource Include="IdnMapping\Data\Unicode_15_1\IdnaTest_15_1.txt" />
<EmbeddedResource Include="IdnMapping\Data\Unicode_16_0\IdnaTest_16.txt" />
<EmbeddedResource Include="IdnMapping\Data\Unicode_17_0\IdnaTest_17.txt" />
<EmbeddedResource Include="Normalization\Data\win8.txt">
<LogicalName>NormalizationDataWin8</LogicalName>
</EmbeddedResource>
Expand Down
Loading