Skip to content

Commit

Permalink
fix: datetime.utc available from python3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
yzqzss committed Aug 11, 2024
1 parent 5ad4501 commit 3dd7c12
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion wikiteam3/dumpgenerator/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def sleep(self, response=None):

config = Config(
curonly = args.curonly,
date = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d"),
date = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%d"),
api = api,
failfast = args.failfast,
http_method = "POST",
Expand Down
2 changes: 1 addition & 1 deletion wikiteam3/dumpgenerator/cli/greeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def welcome():

welcome_string = f"# Welcome to DumpGenerator {getVersion()} by WikiTeam3 (GPL v3)"
welcome_string += " " * (73 - len(welcome_string) - 1) + "#"
copyright_string = f"# Copyright (C) 2011-{datetime.datetime.now(datetime.UTC).year} WikiTeam developers"
copyright_string = f"# Copyright (C) 2011-{datetime.datetime.now(datetime.timezone.utc).year} WikiTeam developers"
copyright_string += " " * (73 - len(copyright_string) - 1) + "#"

return f"""\
Expand Down
2 changes: 1 addition & 1 deletion wikiteam3/dumpgenerator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def asdict(self):
date: str = False
"""
Date of the dump
`datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")`
`datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%d")`
"""

# URL params
Expand Down
2 changes: 1 addition & 1 deletion wikiteam3/dumpgenerator/log/log_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def log_error(config: Config, to_stdout=False , text="") -> None:
if text:
with open(f"{config.path}/errors.log", "a", encoding="utf-8") as outfile:
output = "{}: {}\n".format(
datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d %H:%M:%S"),
datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S"),
text,
)
outfile.write(output)
Expand Down
2 changes: 1 addition & 1 deletion wikiteam3/utils/ia_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def search_ia(apiurl: Optional[str] = None, indexurl: Optional[str] = None, adde

def search_ia_recent(config: Config, days: int = 365):

now_utc = datetime.datetime.now(datetime.UTC)
now_utc = datetime.datetime.now(datetime.timezone.utc)
now_utc_iso = now_utc.strftime("%Y-%m-%dT%H:%M:%SZ")

one_year_ago = now_utc - datetime.timedelta(days=days)
Expand Down
2 changes: 1 addition & 1 deletion wikiteam3/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def mark_as_done(config: Config, mark: str, msg: Optional[str] = None):
if Path(done_path).exists():
return
with open(done_path, "w") as f:
today = datetime.datetime.isoformat(datetime.datetime.now(datetime.UTC))
today = datetime.datetime.isoformat(datetime.datetime.now(datetime.timezone.utc))
f.write(f"{today}: {msg or ''}\n")

return True
Expand Down

0 comments on commit 3dd7c12

Please sign in to comment.