Skip to content

[Maintenance] Tidy up datetime usage for new python versions #8607

Description

@sfayer

Hi,

In datetime.datetime, the utcnow() & utcfromtimestamp() functions are deprecated from python3.12: The replacements for these have been available for a long time, so I suggest tidying them up. There are a few other linked smaller tasks:

  • There are a few uses of strftime("%s") which has better alternatives.
  • NO_LATER_THAN_2050_IN_SEC = int((datetime.strptime("2049-12-31", "%Y-%M-%d") - datetime.now()).total_seconds())
    The %M specifier is minutes, not months, so it's off by ~11 months.
  • There are some uses of datetime.now(), which may well run into issues around daylight-savings changes. These should all be checked and probably converted to UTC or another timezone aware option.

I'm thinking this could be a task for @martynia ?

Regards,
Simon

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions