Skip to content

Commit a25c7d9

Browse files
khellangpakrym
authored andcommitted
Replace custom DateTimeFormatter with ToString("r") or TryFormat (#5695)
1 parent 27f3bd4 commit a25c7d9

File tree

2 files changed

+10
-101
lines changed

2 files changed

+10
-101
lines changed

src/Http/Headers/src/DateTimeFormatter.cs

Lines changed: 0 additions & 100 deletions
This file was deleted.

src/Http/Headers/src/HeaderUtilities.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,16 @@ public static string FormatDate(DateTimeOffset dateTime)
589589

590590
public static string FormatDate(DateTimeOffset dateTime, bool quoted)
591591
{
592-
return dateTime.ToRfc1123String(quoted);
592+
if (quoted)
593+
{
594+
return string.Create(31, dateTime, (span, dt) =>
595+
{
596+
span[0] = span[30] = '"';
597+
dt.TryFormat(span.Slice(1), out _, "r");
598+
});
599+
}
600+
601+
return dateTime.ToString("r");
593602
}
594603

595604
public static StringSegment RemoveQuotes(StringSegment input)

0 commit comments

Comments
 (0)