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

Importing book uses today's values for missing date parts #2660

Closed
texttheater opened this issue Feb 12, 2023 · 5 comments · Fixed by #3038
Closed

Importing book uses today's values for missing date parts #2660

texttheater opened this issue Feb 12, 2023 · 5 comments · Fixed by #3038
Labels
bug Something isn't working

Comments

@texttheater
Copy link

texttheater commented Feb 12, 2023

Describe the bug
When importing a book from OpenLibrary, month and day are set to today's month and day.

To Reproduce
Steps to reproduce the behavior:

  1. Find a book on OpenLibary, e.g., one published in 2022
  2. Import it into a BookWyrm instance, e.g., on Feb 12, 2023

Expected behavior
The book is shown on BookWyrm as published in 2022 (month and date unspecified)

Actual behavior
The book is shown on BookWyrm as published on Feb 12, 2022

Additional context
Related issue: #743

@texttheater texttheater added the bug Something isn't working label Feb 12, 2023
@chdorner
Copy link
Member

I just imported a book today from OpenLibrary which had its published date set correctly.

Do you have a specific book that I could check this with?

@texttheater
Copy link
Author

Are you sure that's correct? On OpenLibrary it just says "2022". On the BookWyrm page you link to it says "13 Feb 2022". Looks like exactly the issue I'm describing.

@chdorner
Copy link
Member

chdorner commented Feb 13, 2023

With the date and month yes, which is most likely related to #743. But the year is set correctly to 2022, not 2023.

@texttheater
Copy link
Author

Sorry, my mistake. Fixed the description now.

@chdorner chdorner changed the title OpenLibrary import makes up published date Importing book uses today's values for missing date parts Feb 13, 2023
@chdorner
Copy link
Member

Did a bit of digging, and this is where it originally happens:

date_value = dateutil.parser.parse(value)

value is set to "2022" coming from OpenLibrary's API and dateutil automatically turns this into datetime.datetime(2022, 2, 13, 0, 0).

In addition, and this is more related to #743, we would need to change how to store this data, it's currently using Django's models.DateTimeField which doesn't support missing day and month parts of a date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants