-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dc084c
commit e5bcfaa
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,29 @@ | ||
from datetime import date, datetime | ||
from ..date_utils import EASTERN_TIME, service_date | ||
|
||
|
||
def test_service_date(): | ||
assert service_date(datetime(2023, 12, 15, 3, 0, 0)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 15, 5, 45, 0)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 15, 7, 15, 0)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 15, 23, 59, 59)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 16, 0, 0, 0)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 16, 2, 59, 59)) == date(2023, 12, 15) | ||
|
||
|
||
def test_localized_datetime(): | ||
assert service_date(datetime(2023, 12, 15, 3, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 15, 5, 45, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 15, 7, 15, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 15, 23, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 16, 0, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) | ||
assert service_date(datetime(2023, 12, 16, 2, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 12, 15) | ||
|
||
|
||
def test_edt_vs_est_datetimes(): | ||
assert service_date(datetime(2023, 11, 5, 23, 59, 59, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) | ||
assert service_date(datetime(2023, 11, 6, 0, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) | ||
assert service_date(datetime(2023, 11, 6, 1, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) | ||
assert service_date(datetime(2023, 11, 6, 2, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 5) | ||
# 3am EST is 4am EDT | ||
assert service_date(datetime(2023, 11, 6, 3, 0, 0, tzinfo=EASTERN_TIME)) == date(2023, 11, 6) |