Skip to content

Conversation

JonnyWong16
Copy link
Collaborator

Description

Sometimes Plex messes up and has incorrect dates in the future. This limits utils.toDatetime() to a maximum 32-bit integer to prevent OverflowError. This will work until January, 2038 (epoch=2^31-1).

Fixes #675

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring for new or existing methods
  • I have added tests when applicable

# And platform support for before epoch seems to be flaky.
# TODO check for others errors too.
if int(value) <= 0:
value = 86400
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this bug do not occur anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should have been if int(value) < 86400.

I just changed it to max(int(value), 86400).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually looks like it works now for me on Windows 10, Python 3.6.8.

Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.fromtimestamp(0)
datetime.datetime(1969, 12, 31, 16, 0)

@Hellowlol Hellowlol merged commit 6e92be6 into pushingkarmaorg:master May 30, 2021
@JonnyWong16 JonnyWong16 deleted the bugfix/to_datetime branch June 7, 2021 02:49
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.

"timestamp out of range" error in library search

2 participants