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 #3677

Merged
merged 4 commits into from
Mar 5, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add fallback to non-exact format during parsing
  • Loading branch information
Dreamescaper committed Feb 27, 2025
commit b0ade5934a0e615c0794b90b18f495f50f7cb508
6 changes: 4 additions & 2 deletions sdk/src/Services/DynamoDBv2/Custom/Conversion/SchemaV1.cs
Original file line number Diff line number Diff line change
@@ -462,7 +462,8 @@ protected override bool TryTo(DateOnly value, out Primitive p)

protected override bool TryFrom(Primitive p, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicConstructors)] Type targetType, out DateOnly result)
{
return DateOnly.TryParseExact(p.StringValue, DateOnlyFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out result);
return DateOnly.TryParseExact(p.StringValue, DateOnlyFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out result)
|| DateOnly.TryParse(p.StringValue, CultureInfo.InvariantCulture, out result);
}
}

@@ -483,7 +484,8 @@ protected override bool TryTo(TimeOnly value, out Primitive p)

protected override bool TryFrom(Primitive p, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicConstructors)] Type targetType, out TimeOnly result)
{
return TimeOnly.TryParseExact(p.StringValue, TimeOnlyFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out result);
return TimeOnly.TryParseExact(p.StringValue, TimeOnlyFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out result)
|| TimeOnly.TryParse(p.StringValue, CultureInfo.InvariantCulture, out result);
}
}
#endif