The documentation for the .ToHtmlString() extension method on DateTime objects says that it formats timestamps in RFC3339 format, but that's not what it actually produces. RFC3339 specifies a date/time format that looks like 2008-06-15T21:15:07.0000000+00:00. But what .ToHtmlString() actually produces is Sun, 15 Jun 2008 21:15:07 GMT.
The reason for this is because the implementation of .ToHtmlString() calls DateTime.ToString("r"), which isn't the RFC3339 format specifier, it's the RFC822 format specifier (the Microsoft docs say it's the RFC1123 format specifier, but if you look at RFC1123, it just refers back to RFC822 for the date format, except for making the change from 2-digit years to 4-digit years). The format specifier that actually produces RFC3339-compliant datetime strings is the "o" format specifier.
At this point it's probably too late to change the implementation of .ToHtmlString() as that would be a breaking change, but I'd like to request another extension method that will call .ToString("o"). I suggest the names .ToIsoString(), .ToIso8601String(), or .ToRfc3339String() for this one; of those three, I prefer .ToIsoString().
Thanks for bringing this to attention. I think .ToIsoString() is a reasonable name. PR welcome!
I took a stab at fixing this issue. Let me know if you have any comments or suggestions about my PR.
@slang25 Now that a fix has been merged in, what's the process to close this defect? I'm not sure what's Giraffe's QA/validation process is?
Let me know if I can do anything to help.
I consider the tests which you added as part of the PR as a reasonable amount of QA for this minor change. It's merged now. @slang25 and I just merged a few PRs and I'm doing a few more bits and plan to release a new version of Giraffe this weekend as it's certainly overdue!
Thanks for your contribution!
Out in 4.0.0