From 1ab45f087f1380ec3db8be033edda88c6ab433b5 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Fri, 13 Oct 2023 23:38:05 +0200 Subject: [PATCH] =?UTF-8?q?MNT:=20`utcnow()`=20=E2=86=92=20`now(tz=3Dtimez?= =?UTF-8?q?one.utc)`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing the current time in UTC is by calling datetime.now(timezone.utc). Deprecated since version 3.12: Use datetime.now() with UTC instead. Co-authored-by: Chris Markiewicz --- niworkflows/tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/niworkflows/tests/conftest.py b/niworkflows/tests/conftest.py index 8aecf747582..0dc40dd7a16 100644 --- a/niworkflows/tests/conftest.py +++ b/niworkflows/tests/conftest.py @@ -23,7 +23,7 @@ """ py.test configuration file """ import os from pathlib import Path -from datetime import datetime as dt +import datetime as dt import pytest from templateflow.api import get as get_template from niworkflows.testing import test_data_env, data_env_canary @@ -34,7 +34,7 @@ def _run_interface_mock(objekt, runtime): runtime.returncode = 0 - runtime.endTime = dt.isoformat(dt.utcnow()) + runtime.endTime = dt.datetime.isoformat(dt.datetime.now(dt.timezone.utc)) objekt._out_report = os.path.abspath(objekt.inputs.out_report) objekt._post_run_hook(runtime)