-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Added - Super basic unittests for `instant_to_datetime` and `timestamp_to_datetime` cause there was a super dumb error which those would have caught ### Changed - The unittest for `any_to_datetime` to account for "instant" ### Fixed - The `any_to_datetime` call where it's accidentally casting "instants" to "timestamps"
- Loading branch information
1 parent
16429a6
commit 3e32227
Showing
6 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = '1.2.0' | ||
__version__ = '1.2.1' | ||
|
||
__author__ = 'Thordur Matthiasson <[email protected]>' | ||
__license__ = 'MIT License' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import unittest | ||
from ccptools.dtu.structs import * | ||
from ccptools.dtu.casting import * | ||
|
||
|
||
def _10_microsec_resolution(dt: Datetime) -> Datetime: | ||
return dt.replace(microsecond=int(dt.microsecond / 10.)*10) | ||
|
||
|
||
class TestInstant(unittest.TestCase): | ||
def test_instant_to_datetime(self): | ||
_dt = Datetime(2024, 5, 22, 10, 37, 54, 123456) | ||
self.assertEqual(_10_microsec_resolution(_dt), _10_microsec_resolution(timestamp_to_datetime(1716374274.123456))) | ||
|
||
_dt = Datetime(1024, 5, 22, 10, 37, 54, 987654) | ||
self.assertEqual(_10_microsec_resolution(_dt), _10_microsec_resolution(timestamp_to_datetime(-29840620925.012344))) | ||
|
||
_dt = Datetime(3024, 5, 22, 10, 37, 54, 123456) | ||
self.assertEqual(_10_microsec_resolution(_dt), _10_microsec_resolution(timestamp_to_datetime(33273283074.123456))) |