Skip to content

Commit

Permalink
Oops, forgot .timetz() too.
Browse files Browse the repository at this point in the history
This commit was sponsored by Jason Walker, and my other patrons.  If
you want to join them, you can support my work at
https://patreon.com/creatorglyph.
  • Loading branch information
glyph committed Nov 7, 2023
1 parent a31a5e6 commit ebf0ca2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/datetype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def isocalendar(self) -> _IsoCalendarDate:
def isocalendar(self) -> tuple[int, int, int]:
...

def timetz(self) -> DateTime[_GMaybeTZDT]:
def timetz(self) -> Time[_GMaybeTZDT]:
...

@classmethod
Expand Down
17 changes: 16 additions & 1 deletion src/datetype/test/test_datetype.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
from typing import runtime_checkable
from unittest import TestCase

from datetype import AwareDateTime, NaiveDateTime, Time, naive
from datetype import (
AwareDateTime,
AwareTime,
NaiveDateTime,
NaiveTime,
Time,
aware,
naive,
)


class DateTypeTests(TestCase):
Expand Down Expand Up @@ -31,6 +39,13 @@ def test_methods(self) -> None:
naiveDT = naive(datetime(2023, 11, 1, 5, 4, 3))
self.assertEqual(naiveDT.date(), date(2023, 11, 1))
self.assertEqual(naiveDT.time(), naive(time(5, 4, 3)))
expectNaiveTime: NaiveTime = naiveDT.timetz()
self.assertEqual(expectNaiveTime, naive(time(5, 4, 3)))
awareDT = aware(datetime(2023, 11, 1, 5, 4, 3, tzinfo=timezone.utc), timezone)
expectAwareTime: Time[timezone] = awareDT.timetz()
self.assertEqual(
expectAwareTime, aware(time(5, 4, 3, tzinfo=timezone.utc), timezone)
)

def test_mypy_output(self) -> None:
"""
Expand Down

0 comments on commit ebf0ca2

Please sign in to comment.