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

Improve parsing to datetime and add error handling #1203

Merged
merged 3 commits into from Aug 27, 2023

Conversation

JonnyWong16
Copy link
Collaborator

@JonnyWong16 JonnyWong16 commented Aug 2, 2023

Description

  • Improve parsing utils.toDatetime() and add error handling.
  • Fix utils.millisecondToHumanstr() for values greater than days and negative values.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

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

@JonnyWong16 JonnyWong16 force-pushed the bugfix/toDatetime branch 2 times, most recently from 73794a0 to 682a7da Compare August 3, 2023 03:51
@JonnyWong16 JonnyWong16 merged commit 3500890 into pkkid:master Aug 27, 2023
3 checks passed
@JonnyWong16 JonnyWong16 deleted the bugfix/toDatetime branch September 18, 2023 00:10
@simonc56
Copy link
Contributor

simonc56 commented Oct 3, 2023

* Improve parsing `utils.toDatetime()` and add error handling.

With python 3.9 this PR not only improves but changes the utils.toDatetime() return.

Before PR, toDatetime() returns a local time (UTC+2 here) :

>>> datetime.datetime.fromtimestamp(1593721093)
datetime.datetime(2020, 7, 2, 22, 18, 13)

After PR, toDatetime() returns a UTC time :

>>> datetime.datetime.utcfromtimestamp(0) + datetime.timedelta(seconds=1593721093)
datetime.datetime(2020, 7, 2, 20, 18, 13)

Do I open a new issue ?

Refs :

@JonnyWong16
Copy link
Collaborator Author

Hmm, yes it should be reverted to fromtimestamp().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants