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

Expiry validation fails on leap days #66

Closed
mxsasha opened this issue Feb 29, 2024 · 1 comment
Closed

Expiry validation fails on leap days #66

mxsasha opened this issue Feb 29, 2024 · 1 comment

Comments

@mxsasha
Copy link
Collaborator

mxsasha commented Feb 29, 2024

The expiry check fails to run any expiry check on a leap day, like today: https://github.com/DigitalTrustCenter/sectxt/blob/27d8524/sectxt/__init__.py#L280

This should probably use now + datetime.timedelta(years=1)

The correct approach is probably expiry_line_date - datetime.datetime.now() <= datetime.timedelta(days=365).

Quick test (executed on leap day):

>>> datetime.datetime(2025, 2, 28) - datetime.datetime.now() <= datetime.timedelta(days=365)
True
>>> datetime.datetime(2025, 3, 1) - datetime.datetime.now() <= datetime.timedelta(days=365)
False
@DigitalTrustCenter
Copy link
Owner

Thank you for reporting this issue. Leap years did fail since it just added a 1 to the year value without accounting for these leap days. It has been improved by using the relativeDelta function on the dateutil package which does account for these leap years,

Your proposed solution would solve the breaking issue with the value error it would not be entirely correct, since it would count a year later in a leap year a day short. However it made it easier to come up with the solution that has been added now so thank you for offering a proposed solution.

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

No branches or pull requests

2 participants