88import sys
99import time
1010from collections .abc import Sequence
11- from datetime import UTC , datetime , timedelta
11+ from datetime import datetime , timedelta , timezone
1212from typing import Any
1313
1414import yaml
@@ -39,7 +39,7 @@ def _emit_stream(value: Any, *, as_json: bool) -> None:
3939
4040
4141def _moment (value : str , * , now : datetime | None = None ) -> datetime :
42- reference = now or datetime .now (UTC )
42+ reference = now or datetime .now (timezone . utc )
4343 match = _DURATION_RE .fullmatch (value .strip ().lower ())
4444 if match :
4545 factors = {"s" : 1 , "m" : 60 , "h" : 3600 , "d" : 86400 }
@@ -52,8 +52,8 @@ def _moment(value: str, *, now: datetime | None = None) -> datetime:
5252 f"invalid time { value !r} ; use an ISO-8601 timestamp or duration such as 30m"
5353 ) from exc
5454 if parsed .tzinfo is None :
55- parsed = parsed .replace (tzinfo = UTC )
56- return parsed .astimezone (UTC )
55+ parsed = parsed .replace (tzinfo = timezone . utc )
56+ return parsed .astimezone (timezone . utc )
5757
5858
5959def _health_options (args : argparse .Namespace ) -> dict [str , Any ]:
@@ -227,7 +227,7 @@ def _execute(args: argparse.Namespace, config: StandConfig) -> int:
227227 elif args .format == "raw" and args .node != "all" and not has_filters and not args .json :
228228 manager .logs (args .node , tail = args .tail )
229229 else :
230- now = datetime .now (UTC )
230+ now = datetime .now (timezone . utc )
231231 records = manager .log_records (
232232 args .node ,
233233 tail = args .tail ,
@@ -244,7 +244,7 @@ def _execute(args: argparse.Namespace, config: StandConfig) -> int:
244244 elif args .command == "events" :
245245 if args .follow and args .until :
246246 raise DockerRuntimeError ("events --follow cannot be combined with --until" )
247- now = datetime .now (UTC )
247+ now = datetime .now (timezone . utc )
248248 since = int (_moment (args .since , now = now ).timestamp ())
249249 until = (
250250 None
0 commit comments