Skip to content

types: add support RFC 110 expanded year format#127

Merged
patjakdev merged 2 commits intocedar-policy:mainfrom
strongdm:rfc-110-expanded-year
Jan 29, 2026
Merged

types: add support RFC 110 expanded year format#127
patjakdev merged 2 commits intocedar-policy:mainfrom
strongdm:rfc-110-expanded-year

Conversation

@patjakdev
Copy link
Copy Markdown
Collaborator

@patjakdev patjakdev commented Jan 29, 2026

Issue #, if available:
#128

Description of changes:

This change adds support for the nine-digit expanded year datetime format specified in RFC 110, allowing exotic datetimes far in the past or future to be represented in Cedar policies and entities.

Incidentally, it also fixes a bug in the Datetime type where timezone offset was being interpreted incorrectly (see #128).

@patjakdev patjakdev force-pushed the rfc-110-expanded-year branch 4 times, most recently from d03baa3 to 327dd3b Compare January 29, 2026 02:47
@patjakdev patjakdev marked this pull request as ready for review January 29, 2026 02:49
@patjakdev patjakdev requested review from apg and philhassey January 29, 2026 02:50

if s[13] != ':' {
return Datetime{}, fmt.Errorf("%w: unexpected character %s", errDatetime, strconv.QuoteRune(rune(s[13])))
if hour, s, err = parseTwoCharacterUint(s, 23, "hour"); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All of this seems like there should be a single function that is just parseUint(s, expectedLen, maxVal, name)

And use that for all the components, not just for some of them.


if s[10] != 'T' {
return Datetime{}, fmt.Errorf("%w: unexpected character %s", errDatetime, strconv.QuoteRune(rune(s[10])))
if err = checkValidDay(year, month, day); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like you should throw in hour, minute, second as well, and use the other methods on date .Hour(), .Minute(), .Second() to validate that yes this is exactly what it is. (This should help in cases of leap seconds maybe?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This check is just about validating that the day is valid for the given month/year. The other values are validated by their maxValue, day is the only one whose max value depends on other values.

If you're talking about the checks for the minimum and maximum timestamp, I neglected to even do that checking in the original PR. Hopefully the code I've added makes that clear.

Copy link
Copy Markdown
Contributor

@philhassey philhassey left a comment

Choose a reason for hiding this comment

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

A few suggestions and a few nits and a few tests might be worth addressing here.

I think my thoughts on validating h:m:s are probably not valid thoughts. But the other changes seemed reasonable.

@patjakdev patjakdev force-pushed the rfc-110-expanded-year branch 2 times, most recently from 3858eaf to b6f3b6d Compare January 29, 2026 18:29
An offset of +0100 indicates that 1 hour should be _subtracted_ from the time in order to produce UTC rather than added.

Signed-Off-By: Patrick Jakubowski <patrick.jakubowski@strongdm.com>
@patjakdev patjakdev force-pushed the rfc-110-expanded-year branch 3 times, most recently from f699039 to b6460fd Compare January 29, 2026 18:56
Copy link
Copy Markdown
Contributor

@philhassey philhassey left a comment

Choose a reason for hiding this comment

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

LGTM

This change adds support for the nine-digit expanded year datetime format specified in RFC 110, allowing exotic datetimes far in the past or future to be represented in Cedar policies and entities.

Signed-Off-By: Patrick Jakubowski <patrick.jakubowski@strongdm.com>
@patjakdev patjakdev force-pushed the rfc-110-expanded-year branch from b6460fd to c1177bf Compare January 29, 2026 19:38
@patjakdev patjakdev merged commit 2a36626 into cedar-policy:main Jan 29, 2026
2 checks passed
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.

2 participants