From 86279da383503415ee21fa5ec3824cb0d710263c Mon Sep 17 00:00:00 2001 From: James Davies Date: Thu, 18 Jan 2024 11:44:16 +0100 Subject: [PATCH] Fix datetime.utcnow() deprecation --- src/stpipe/config.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stpipe/config.py b/src/stpipe/config.py index b7c79a09..a9178667 100644 --- a/src/stpipe/config.py +++ b/src/stpipe/config.py @@ -4,7 +4,7 @@ both until we replace configobj with traitlets. """ from copy import deepcopy -from datetime import datetime +from datetime import UTC, datetime import asdf @@ -111,7 +111,10 @@ def to_asdf(self, include_metadata=False): meta = deepcopy(_META_TEMPLATE) meta["date"] = meta["date"].replace( _TEMPLATE_PLACEHOLDER, - datetime.utcnow().replace(microsecond=0).isoformat(), + datetime.now(UTC) + .replace(microsecond=0) + .isoformat() + .removesuffix("+00:00"), ) meta["description"] = meta["description"].replace( _TEMPLATE_PLACEHOLDER, self.class_name