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

[python] use datetime aware object #5209

Merged
merged 8 commits into from
Feb 6, 2020

Conversation

sebastien-rosset
Copy link
Contributor

@sebastien-rosset sebastien-rosset commented Feb 5, 2020

Add timezone information to datetime, otherwise the calculation of UNIX time may be incorrect, depending on the platform and local time configuration.

datetime.now() returns the current local date and time. If optional argument tz is None or not specified, this is like today(), but, if possible, supplies more precision than can be gotten from going through a time.time() timestamp (for example, this may be possible on platforms supplying the C gettimeofday() function).
This means the value of now() is not deterministic across platforms unless the timezone information is provided. As a result, on some platforms the "created" and "expires" fields are set incorrectly and cause the server side to conclude the signature is incorrect.

Also, need to handle python 2.7 and python 3.x.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

Copy link
Contributor

@spacether spacether left a comment

Choose a reason for hiding this comment

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

@sebastien-rosset thank you for this PR!
It looks good.

@spacether spacether merged commit cc0fe06 into OpenAPITools:master Feb 6, 2020
MikailBag pushed a commit to MikailBag/openapi-generator that referenced this pull request Mar 23, 2020
* python use aware datetime object

* python use aware datetime object

* python use aware datetime object

* python use aware datetime object

* python use aware datetime object

* python use aware datetime object
@wing328 wing328 added this to the 4.3.0 milestone Mar 26, 2020
@sebastien-rosset sebastien-rosset deleted the python-datetime-timezone branch May 23, 2020 19:26
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.

3 participants