Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Improve DateTime{Offset} "r" and "o" formatting performance #17092

Merged
merged 1 commit into from
Mar 21, 2018
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
18 changes: 9 additions & 9 deletions src/mscorlib/shared/System/DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1255,46 +1255,46 @@ internal DateTime ToLocalTime(bool throwOnOverflow)

public String ToLongDateString()
{
return DateTimeFormat.Format(this, "D", DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, "D", null);
}

public String ToLongTimeString()
{
return DateTimeFormat.Format(this, "T", DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, "T", null);
}

public String ToShortDateString()
{
return DateTimeFormat.Format(this, "d", DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, "d", null);
}

public String ToShortTimeString()
{
return DateTimeFormat.Format(this, "t", DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, "t", null);
}

public override String ToString()
{
return DateTimeFormat.Format(this, null, DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, null, null);
}

public String ToString(String format)
{
return DateTimeFormat.Format(this, format, DateTimeFormatInfo.CurrentInfo);
return DateTimeFormat.Format(this, format, null);
}

public String ToString(IFormatProvider provider)
{
return DateTimeFormat.Format(this, null, DateTimeFormatInfo.GetInstance(provider));
return DateTimeFormat.Format(this, null, provider);
}

public String ToString(String format, IFormatProvider provider)
{
return DateTimeFormat.Format(this, format, DateTimeFormatInfo.GetInstance(provider));
return DateTimeFormat.Format(this, format, provider);
}

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider provider = null) =>
DateTimeFormat.TryFormat(this, destination, out charsWritten, format, DateTimeFormatInfo.GetInstance(provider));
DateTimeFormat.TryFormat(this, destination, out charsWritten, format, provider);

public DateTime ToUniversalTime()
{
Expand Down
10 changes: 5 additions & 5 deletions src/mscorlib/shared/System/DateTimeOffset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -755,26 +755,26 @@ internal DateTimeOffset ToLocalTime(bool throwOnOverflow)

public override String ToString()
{
return DateTimeFormat.Format(ClockDateTime, null, DateTimeFormatInfo.CurrentInfo, Offset);
return DateTimeFormat.Format(ClockDateTime, null, null, Offset);
}

public String ToString(String format)
{
return DateTimeFormat.Format(ClockDateTime, format, DateTimeFormatInfo.CurrentInfo, Offset);
return DateTimeFormat.Format(ClockDateTime, format, null, Offset);
}

public String ToString(IFormatProvider formatProvider)
{
return DateTimeFormat.Format(ClockDateTime, null, DateTimeFormatInfo.GetInstance(formatProvider), Offset);
return DateTimeFormat.Format(ClockDateTime, null, formatProvider, Offset);
}

public String ToString(String format, IFormatProvider formatProvider)
{
return DateTimeFormat.Format(ClockDateTime, format, DateTimeFormatInfo.GetInstance(formatProvider), Offset);
return DateTimeFormat.Format(ClockDateTime, format, formatProvider, Offset);
}

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider formatProvider = null) =>
DateTimeFormat.TryFormat(ClockDateTime, destination, out charsWritten, format, DateTimeFormatInfo.GetInstance(formatProvider), Offset);
DateTimeFormat.TryFormat(ClockDateTime, destination, out charsWritten, format, formatProvider, Offset);

public DateTimeOffset ToUniversalTime()
{
Expand Down
Loading