|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from collections.abc import Collection, Sequence |
| 4 | +from datetime import datetime |
4 | 5 | from typing import Any, Literal |
5 | 6 |
|
6 | 7 | from typing_extensions import Self |
7 | 8 |
|
8 | 9 | from cognite.client.data_classes._base import CogniteFilter, CogniteResource, UnknownCogniteResource |
| 10 | +from cognite.client.utils._time import timestamp_to_ms |
9 | 11 |
|
10 | 12 |
|
11 | 13 | class TimestampRange(CogniteResource): |
12 | 14 | """Range between two timestamps. |
13 | 15 |
|
14 | 16 | Args: |
15 | | - max (int | None): The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds. |
16 | | - min (int | None): The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds. |
| 17 | + max (int | float | str | datetime | None): The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds, a string in time-shift format or a datetime object. |
| 18 | + min (int | float | str | datetime | None): The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds, a string in time-shift format or a datetime object. |
17 | 19 | **_ (Any): No description. |
18 | 20 | """ |
19 | 21 |
|
20 | | - def __init__(self, max: int | None = None, min: int | None = None, **_: Any) -> None: |
21 | | - self.max = max |
22 | | - self.min = min |
| 22 | + def __init__( |
| 23 | + self, max: int | float | str | datetime | None = None, min: int | float | str | datetime | None = None, **_: Any |
| 24 | + ) -> None: |
| 25 | + self.max = timestamp_to_ms(max) if max is not None else None |
| 26 | + self.min = timestamp_to_ms(min) if min is not None else None |
23 | 27 |
|
24 | 28 | @classmethod |
25 | 29 | def _load(cls, resource: dict[str, Any]) -> Self: |
|
0 commit comments