summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs')
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs
index 61143fecfd..b105324a6b 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs
@@ -509,7 +509,7 @@ namespace System
fraction = fraction / (long)Math.Pow(10, 7 - tokenLen);
if (ch == 'f')
{
- result.Append(((int)fraction).ToString(fixedNumberFormats[tokenLen - 1], CultureInfo.InvariantCulture));
+ result.AppendSpanFormattable((int)fraction, fixedNumberFormats[tokenLen - 1], CultureInfo.InvariantCulture);
}
else
{
@@ -528,7 +528,7 @@ namespace System
}
if (effectiveDigits > 0)
{
- result.Append(((int)fraction).ToString(fixedNumberFormats[effectiveDigits - 1], CultureInfo.InvariantCulture));
+ result.AppendSpanFormattable((int)fraction, fixedNumberFormats[effectiveDigits - 1], CultureInfo.InvariantCulture);
}
else
{
@@ -679,10 +679,13 @@ namespace System
{
FormatDigits(result, year % 100, tokenLen);
}
+ else if (tokenLen <= 16) // FormatDigits has an implicit 16-digit limit
+ {
+ FormatDigits(result, year, tokenLen, overrideLengthLimit: true);
+ }
else
{
- string fmtPattern = "D" + tokenLen.ToString();
- result.Append(year.ToString(fmtPattern, CultureInfo.InvariantCulture));
+ result.Append(year.ToString("D" + tokenLen.ToString(), CultureInfo.InvariantCulture));
}
}
bTimeOnly = false;