-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add DateOnly and TimeOnly converters #503
Conversation
libraries/src/AWS.Lambda.Powertools.Logging/Internal/LoggingAspectHandler.cs
Outdated
Show resolved
Hide resolved
libraries/src/AWS.Lambda.Powertools.Logging/Internal/LoggingAspectHandler.cs
Outdated
Show resolved
Hide resolved
libraries/src/AWS.Lambda.Powertools.Logging/Internal/LoggingAspectHandler.cs
Outdated
Show resolved
Hide resolved
/// <returns></returns> | ||
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
return DateOnly.ParseExact(reader.GetString()!, DateFormat, CultureInfo.InvariantCulture); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think if we need to read, you could also throw not implemented exception, but no harm to leave the logic.
/// <returns></returns> | ||
public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
return TimeOnly.ParseExact(reader.GetString()!, TimeFormat, CultureInfo.InvariantCulture); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think if we need to read, you could also throw not implemented exception, but no harm to leave the logic.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue number: #501
Summary
.NET 6 is missing DateOnly and TimeOnly Json converters. This is causing issues serializing these two types.
Changes
Added two new converters for DateOnly and TimeOnly.
User experience
Logging will handle DateOnly fields without any additional or custom logic from application developers.
Checklist
Please leave checklist items unchecked if they do not apply to your change.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.