Skip to content

Lean: Add parsing for duration in the datetime extension#471

Merged
adpaco-aws merged 8 commits intocedar-policy:mainfrom
adpaco-aws:parse-duration
Nov 25, 2024
Merged

Lean: Add parsing for duration in the datetime extension#471
adpaco-aws merged 8 commits intocedar-policy:mainfrom
adpaco-aws:parse-duration

Conversation

@adpaco-aws
Copy link
Copy Markdown
Contributor

Issue #, if available: N/A

Description of changes

This PR adds parsing for duration strings in the datetime extension which is being introduced to the Lean models.

We define a parse function that attempts to parse a duration string from the back. This helps us avoid an issue with respect to our previous forward version where this greedy approach leads to failures due to the m unit being a substring of the ms unit. The changes also include unit tests for parsing duration strings.

Callouts

  • This is my first contribution in Lean so I'm open to all kinds of feedback.
  • It's likely that I'll later add a parse function for datetime values, so I'm not sure what's the best way to name the parse in these changes. Do we want another namespace for the duration definitions?

@adpaco-aws adpaco-aws requested a review from emina November 8, 2024 21:44
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Copy link
Copy Markdown
Contributor

@emina emina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Left some comments.

Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Comment thread cedar-lean/UnitTest/Datetime.lean
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Comment thread cedar-lean/Cedar/Spec/Ext/Datetime.lean Outdated
Signed-off-by: Adrian Palacios <accorell@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants