Skip to content
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

Support DateOnly / TimeOnly in DynamoDBContext #3673

Open
1 of 2 tasks
Dreamescaper opened this issue Feb 26, 2025 · 5 comments
Open
1 of 2 tasks

Support DateOnly / TimeOnly in DynamoDBContext #3673

Dreamescaper opened this issue Feb 26, 2025 · 5 comments
Labels
dynamodb feature-request A feature should be added or improved. p2 This is a standard priority issue

Comments

@Dreamescaper
Copy link
Contributor

Describe the feature

I would be nice if DynamoDBContext supported DateOnly / TimeOnly properties natively.
Currently users have to implement custom converters to allow that.

Use Case

Storing data which has only date information, without time.

Proposed Solution

Add

  • DateOnlyConverterV1
  • TimeOnlyConverterV1
  • DateOnlyConverterV2
  • TimeOnlyConverterV2

(Behavior is identical for both versions).

DateOnly / TimeOnly types are not available in netstandard, so this functionality should only be available for supported target frameworks.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

AWSSDK.DynamoDBv2 3.7.405.28

Targeted .NET Platform

.NET 8

Operating System and version

AmazonLinux

@Dreamescaper Dreamescaper added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 26, 2025
@Dreamescaper
Copy link
Contributor Author

I'm willing to implement this functionality if it is approved.

@ashishdhingra
Copy link
Contributor

Refer How to use the DateOnly and TimeOnly structures. Needs review with the team.

@ashishdhingra ashishdhingra added dynamodb p2 This is a standard priority issue needs-review and removed needs-triage This issue or PR still needs to be triaged. labels Feb 26, 2025
@normj
Copy link
Member

normj commented Feb 27, 2025

I'm thinking the changes would be localized to the converters and some list containing the list of converters. So as long as the change is for the most part contained in that area and we don't have to add a lot of #if conditionals in the rest of the HLL's codebase for .NET Standard+ I'm okay adding the feature.

I assume the actual format being saved in DDB for these time data types should be the same we use DateTime just with the non-relevant part basically "zeroed" out. That way a .NET Framework user could still access the data but they would need to use a DateTime.

@Dreamescaper
Copy link
Contributor Author

Dreamescaper commented Feb 27, 2025

I'm thinking the changes would be localized to the converters and some list containing the list of converters.

Yeah, it should affect DynamoDBEntryConversion (SetVxConvertions), SchemaV1, SchemaV2.

I assume the actual format being saved in DDB for these time data types should be the same we use DateTime just with the non-relevant part basically "zeroed" out. That way a .NET Framework user could still access the data but they would need to use a DateTime.

DynamoDB uses "yyyy-MM-dd\\THH:mm:ss.fff\\Z" format for DateTime for writing.
I was thinking of "yyyy-MM-dd" for DateOnly, and "HH:mm:ss.fff" for TimeOnly.

DateTimeConverter has a fallback to non-exact format on reading, so it will be able to parse both of those formats if someone needs it:
sharplab

@normj
Copy link
Member

normj commented Feb 27, 2025

DynamoDB uses "yyyy-MM-dd\\THH:mm:ss.fff\\Z" format for DateTime for writing. I was thinking of "yyyy-MM-dd" for DateOnly, and "HH:mm:ss.fff" for TimeOnly.

DateTimeConverter has a fallback to non-exact format on reading, so it will be able to parse both of those formats if someone needs it:

That works for me. Thanks for confirming the DateTime parse with the shorten formatting for these types will work in the fallback parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamodb feature-request A feature should be added or improved. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants