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

Fix date parsing for kingston.gov.uk. Fixes #3224 #3225

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cmsj
Copy link

@cmsj cmsj commented Dec 17, 2024

Date parsing is now in its own function because it has grown in complexity. Kingston has stopped including years in their dates, so we have to add them manually and account for year boundaries.

@cmsj cmsj changed the title Fix date parsing for kingston.gov.uk Fix date parsing for kingston.gov.uk. Fixes #3224 Dec 17, 2024
now = datetime.now()
date = datetime.strptime(date_string + f" {now.year}", "%A %d %B %Y")

if date < now:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is also true for collections on the current date so they will be moved to the next year. You could resolve this by converting now and date from datetime objects to date objects before this instead of at the end of the function.

@5ila5
Copy link
Collaborator

5ila5 commented Dec 18, 2024

You could also use the dateutil.parse.parse function, which might be more resilient against future changes

@5ila5 5ila5 linked an issue Dec 18, 2024 that may be closed by this pull request
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.

Kingston.gov.uk appears to have changed date formats again
2 participants