Skip to content

datetime: support big values for some platforms #311

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

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

DifferentialOrange
Copy link
Member

Before this patch, tarantool.Datetime constructor used datetime.fromtimestamp function to build a new datetime [1], except for negative timestamps for Windows platform. This constructor branch is used on each Tarantool datetime encoding or while building a tarantool.Datetime object from timestamp. datetime.fromtimestamp have some drawbacks: it "may raise OverflowError, if the timestamp is out of the range of values supported by the platform C localtime() or gmtime() functions, and OSError on localtime() or gmtime() failure. It’s common for this to be restricted to years in 1970 through 2038.". It had never happened on supported Unix platforms, but seem to be an issue for Windows ones. We already workaround this issue for years smaller than 1970 on Windows. After this patch, this workaround will be used for all platforms and timestamp values, allowing to provide similar behavior for platforms both restricted to years in 1970 through 2038 with localtime() or gmtime() or not.

  1. https://docs.python.org/3/library/datetime.html#datetime.datetime.fromtimestamp

Copy link
Contributor

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Thank you for the patch!

@DifferentialOrange DifferentialOrange changed the base branch from DifferentialOrange/crud-error-rethrow to master September 20, 2023 06:12
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/big-datetime branch 2 times, most recently from ae9ea59 to 7b9abe2 Compare September 20, 2023 06:20
Before this patch, tarantool.Datetime constructor used
datetime.fromtimestamp function to build a new datetime [1], except for
negative timestamps for Windows platform. This constructor branch is
used on each Tarantool datetime encoding or while building
a tarantool.Datetime object from timestamp. datetime.fromtimestamp have
some drawbacks: it "may raise OverflowError, if the timestamp is out of
the range of values supported by the platform C localtime() or gmtime()
functions, and OSError on localtime() or gmtime() failure. It’s common
for this to be restricted to years in 1970 through 2038.". It had never
happened on supported Unix platforms, but seem to be an issue for
Windows ones. We already workaround this issue for years smaller than
1970 on Windows. After this patch, this workaround will be used for
all platforms and timestamp values, allowing to provide similar
behavior for platforms both restricted to years in 1970 through 2038
with localtime() or gmtime() or not.

1. https://docs.python.org/3/library/datetime.html#datetime.datetime.fromtimestamp
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/big-datetime branch from 7b9abe2 to 0f7f91b Compare September 20, 2023 06:24
@DifferentialOrange DifferentialOrange merged commit 90402e8 into master Sep 20, 2023
@DifferentialOrange DifferentialOrange deleted the DifferentialOrange/big-datetime branch September 20, 2023 06:42
DifferentialOrange added a commit that referenced this pull request Sep 20, 2023
Overview

  This release introduce several bugfixes and behavior improvements.

Fixed

  - Exception rethrow in crud API (PR #310).
  - Work with timestamps larger than year 2038 for some platforms
    (like Windows) (PR #311). It covers
    - building new `tarantool.Datetime` objects from timestamp,
    - parsing datetime objects received from Tarantool.
@DifferentialOrange DifferentialOrange mentioned this pull request Sep 20, 2023
DifferentialOrange added a commit that referenced this pull request Sep 20, 2023
Overview

  This release introduce several bugfixes and behavior improvements.

Fixed

  - Exception rethrow in crud API (PR #310).
  - Work with timestamps larger than year 2038 for some platforms
    (like Windows) (PR #311). It covers
    - building new `tarantool.Datetime` objects from timestamp,
    - parsing datetime objects received from Tarantool.
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.

2 participants