Skip to content

Commit

Permalink
Fix datetime.utcnow() deprecation (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Jan 18, 2024
2 parents 9e7c441 + 8b120a0 commit bb73636
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- macos: py311-xdist
- linux: py311-cov-xdist
coverage: 'codecov'
- linux: py312-xdist
test_downstream:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fix regex issue in internal configobj [#108]
- Remove bundled ``configobj`` package in favor of the ``configobj`` package
bundled into ``astropy``. [#122]
- Fix ``datetime.utcnow()`` DeprecationWarning [#134]

0.5.1 (2023-10-02)
==================
Expand Down
7 changes: 5 additions & 2 deletions src/stpipe/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
both until we replace configobj with traitlets.
"""
from copy import deepcopy
from datetime import datetime
from datetime import datetime, timezone

import asdf

Expand Down Expand Up @@ -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(timezone.utc)
.replace(microsecond=0)
.isoformat()
.removesuffix("+00:00"),
)
meta["description"] = meta["description"].replace(
_TEMPLATE_PLACEHOLDER, self.class_name
Expand Down

0 comments on commit bb73636

Please sign in to comment.