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

Fixed negative timestamps parsing for windows #230

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

pabloitu
Copy link
Collaborator

@pabloitu pabloitu commented May 31, 2023

Added a bypass of time_utils for Windows OS users, which creates datetime objects from negative timestamps/epochs.

Type of change:

Please delete options that are not relevant.

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

Checklist:

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 20.00% and project coverage change: -0.10 ⚠️

Comparison is base (97ba99e) 55.05% compared to head (8dde8bb) 54.95%.

❗ Current head 8dde8bb differs from pull request most recent head 829df9a. Consider uploading reports for the commit 829df9a to get more accurate results

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #230      +/-   ##
==========================================
- Coverage   55.05%   54.95%   -0.10%     
==========================================
  Files          23       23              
  Lines        3954     3963       +9     
  Branches      576      578       +2     
==========================================
+ Hits         2177     2178       +1     
- Misses       1641     1648       +7     
- Partials      136      137       +1     
Impacted Files Coverage Δ
csep/utils/time_utils.py 57.36% <20.00%> (-3.47%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@fabiolsilva fabiolsilva left a comment

Choose a reason for hiding this comment

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

Looks good, also we should add windows to the GitHub testing matrix.

@@ -50,5 +50,8 @@ def test_decimal_year_epoch(self):
test_year = decimal_year(epoch_time_to_utc_datetime(epoch))
self.assertAlmostEqual(year, test_year)



def test_negative_epoch(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Included test to check if negative timestamps are working properly.

epoch_time = epoch_time_milli / 1000
dt = datetime.datetime.fromtimestamp(epoch_time, datetime.timezone.utc)

if os.name == "nt" and epoch_time < 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

When using Windows, check for negative timestamps, and handle it properly.

@fabiolsilva fabiolsilva merged commit 5ce536d into SCECcode:master Aug 9, 2023
@pabloitu pabloitu deleted the fix_datetime_windows branch August 16, 2024 13:29
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