Skip to content

as_datetime: Set upper limit#193

Open
Akasurde wants to merge 1 commit into
ansible-collections:mainfrom
Akasurde:i182
Open

as_datetime: Set upper limit#193
Akasurde wants to merge 1 commit into
ansible-collections:mainfrom
Akasurde:i182

Conversation

@Akasurde
Copy link
Copy Markdown
Member

SUMMARY
  • Set upper limit to avoid overflowerror

Fixes: #182

Signed-off-by: Abhijeet Kasurde Akasurde@redhat.com

ISSUE TYPE
  • Bugfix Pull Request

* Set upper limit to avoid overflowerror

Fixes: ansible-collections#182

Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
@softwarefactory-project-zuul
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@jborean93 jborean93 left a comment

Choose a reason for hiding this comment

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

We should also update the documentation to state that the max cap of a date is 9999-12-31T23:59:59.999999+0000 and any FILETIME value above that will be set to that.

if isinstance(value, str):
value = int(value)

if value >= 9223372036854775807: # 2^63 - 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks like the max value supported is actually 2650467743999999999, any value beyond that represents a datetime after year 9999. You have to add 9 to the value below as that's 900 nanoseconds which you can't represent in the DateTime constructor but we essentially ignore that level of precision.

[DateTime]::new(9999, 12, 31, 23, 59, 59, 999, 999, 'Utc').ToUniversalTime().ToFileTime()
2650467743999999990

year=datetime.MAXYEAR,
month=12,
day=31,
tzinfo=datetime.timezone.utc,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should probably set the time portion to the max and not just the date.

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.

The filter microsoft.ad.as_datetime fails when a user has "Account never expires" set.

2 participants