Skip to content

Commit 1229c18

Browse files
authored
fix: use microsecond level precision for inclusive end dates (#2128)
1 parent fc6269c commit 1229c18

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sqlmesh/utils/date.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def make_inclusive(start: TimeLike, end: TimeLike) -> Interval:
273273
274274
Example:
275275
>>> make_inclusive("2020-01-01", "2020-01-01")
276-
(datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2020, 1, 1, 23, 59, 59, 999000, tzinfo=datetime.timezone.utc))
276+
(datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2020, 1, 1, 23, 59, 59, 999999, tzinfo=datetime.timezone.utc))
277277
278278
Returns:
279279
A tuple of inclusive datetime objects.
@@ -285,7 +285,7 @@ def make_inclusive_end(end: TimeLike) -> datetime:
285285
end_dt = to_datetime(end)
286286
if is_date(end):
287287
end_dt = end_dt + timedelta(days=1)
288-
return end_dt - timedelta(milliseconds=1)
288+
return end_dt - timedelta(microseconds=1)
289289

290290

291291
def validate_date_range(

tests/utils/test_date.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,25 @@ def test_to_timestamp() -> None:
6868
@pytest.mark.parametrize(
6969
"start_in, end_in, start_out, end_out",
7070
[
71-
("2020-01-01", "2020-01-01", "2020-01-01", "2020-01-01 23:59:59.999000"),
72-
("2020-01-01", date(2020, 1, 1), "2020-01-01", "2020-01-01 23:59:59.999000"),
71+
("2020-01-01", "2020-01-01", "2020-01-01", "2020-01-01 23:59:59.999999"),
72+
("2020-01-01", date(2020, 1, 1), "2020-01-01", "2020-01-01 23:59:59.999999"),
7373
(
7474
date(2020, 1, 1),
7575
date(2020, 1, 1),
7676
"2020-01-01",
77-
"2020-01-01 23:59:59.999000",
77+
"2020-01-01 23:59:59.999999",
7878
),
7979
(
8080
"2020-01-01",
8181
"2020-01-01 12:00:00",
8282
"2020-01-01",
83-
"2020-01-01 11:59:59.99900",
83+
"2020-01-01 11:59:59.999999",
8484
),
8585
(
8686
"2020-01-01",
8787
to_datetime("2020-01-02"),
8888
"2020-01-01",
89-
"2020-01-01 23:59:59.999000",
89+
"2020-01-01 23:59:59.999999",
9090
),
9191
],
9292
)

0 commit comments

Comments
 (0)