[csharp] Output DateOnly paramater in the correct default format (#19728) (#19729)

* Output DateOnly in the correct default format

* Only add conditional if we are net60 or later

* Update samples
This commit is contained in:
Alec Petersen
2024-10-06 22:48:50 -04:00
committed by GitHub
parent fce8bb9604
commit c7d9857c8d
6 changed files with 38 additions and 0 deletions

View File

@@ -101,6 +101,12 @@ namespace Org.OpenAPITools.Client
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
if (obj is DateOnly dateOnly)
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15
return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
if (obj is bool boolean)
return boolean ? "true" : "false";
if (obj is ICollection collection) {