aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-11-25 18:18:09 +0000
committerGravatar jesopo2019-11-25 18:18:09 +0000
commit93aea08818252dd65a02a31894bfeea9fc0e45b9 (patch)
tree2de12f1bb644bd37c90c8f7d151b7a5b715ff7aa
parentadd `cookies` and `.json()` to utils.http.Response objects (diff)
signature
utils.datetime.datetime_utcnow() -> utils.datetime.utcnow()
-rw-r--r--modules/badges.py6
-rw-r--r--modules/lastfm.py2
-rw-r--r--src/LockFile.py6
-rw-r--r--src/utils/datetime.py4
4 files changed, 9 insertions, 9 deletions
diff --git a/modules/badges.py b/modules/badges.py
index 631e7ccd..5aa16015 100644
--- a/modules/badges.py
+++ b/modules/badges.py
@@ -9,7 +9,7 @@ HUMAN_FORMAT_HELP = "year-month-day (e.g. 2018-12-29)"
class Module(ModuleManager.BaseModule):
def _parse_date(self, dt: str):
if dt.lower() == "today":
- return utils.datetime.datetime_utcnow()
+ return utils.datetime.utcnow()
else:
match = RE_HUMAN_FORMAT.match(dt)
if not match:
@@ -52,7 +52,7 @@ class Module(ModuleManager.BaseModule):
badge_lower = badge.lower()
badges = self._get_badges(event["user"])
- now = self._round_up_day(utils.datetime.datetime_utcnow())
+ now = self._round_up_day(utils.datetime.utcnow())
found_badge = self._find_badge(badges, badge)
@@ -74,7 +74,7 @@ class Module(ModuleManager.BaseModule):
if event["args"]:
user = event["server"].get_user(event["args_split"][0])
- now = self._round_up_day(utils.datetime.datetime_utcnow())
+ now = self._round_up_day(utils.datetime.utcnow())
badges = []
for badge, date in self._get_badges(user).items():
days_since = self._days_since(now,
diff --git a/modules/lastfm.py b/modules/lastfm.py
index ce69abcf..14e9128a 100644
--- a/modules/lastfm.py
+++ b/modules/lastfm.py
@@ -54,7 +54,7 @@ class Module(ModuleManager.BaseModule):
np = True
else:
played = int(now_playing["date"]["uts"])
- dt = utils.datetime.datetime_utcnow()
+ dt = utils.datetime.utcnow()
np = bool((dt.timestamp()-played) < 120)
time_language = "is listening to" if np else "last listened to"
diff --git a/src/LockFile.py b/src/LockFile.py
index 309e8e87..54ff6284 100644
--- a/src/LockFile.py
+++ b/src/LockFile.py
@@ -9,7 +9,7 @@ class LockFile(PollHook.PollHook):
self._next_lock = None
def available(self):
- now = utils.datetime.datetime_utcnow()
+ now = utils.datetime.utcnow()
if os.path.exists(self._filename):
with open(self._filename, "r") as lock_file:
timestamp_str = lock_file.read().strip().split(" ", 1)[0]
@@ -23,14 +23,14 @@ class LockFile(PollHook.PollHook):
def lock(self):
with open(self._filename, "w") as lock_file:
- last_lock = utils.datetime.datetime_utcnow()
+ last_lock = utils.datetime.utcnow()
lock_file.write("%s" % utils.datetime.iso8601_format(last_lock))
self._next_lock = last_lock+datetime.timedelta(
seconds=EXPIRATION/2)
def next(self):
return max(0,
- (self._next_lock-utils.datetime.datetime_utcnow()).total_seconds())
+ (self._next_lock-utils.datetime.utcnow()).total_seconds())
def call(self):
self.lock()
diff --git a/src/utils/datetime.py b/src/utils/datetime.py
index 0fac2bb3..3ed03088 100644
--- a/src/utils/datetime.py
+++ b/src/utils/datetime.py
@@ -10,7 +10,7 @@ ISO8601_FORMAT_TZ = "%z"
DATETIME_HUMAN = "%Y/%m/%d %H:%M:%S"
DATE_HUMAN = "%Y-%m-%d"
-def datetime_utcnow() -> _datetime.datetime:
+def utcnow() -> _datetime.datetime:
return _datetime.datetime.utcnow().replace(tzinfo=_datetime.timezone.utc)
def datetime_timestamp(seconds: float) -> _datetime.datetime:
return _datetime.datetime.fromtimestamp(seconds).replace(
@@ -26,7 +26,7 @@ def iso8601_format(dt: _datetime.datetime, milliseconds: bool=False) -> str:
return "%s%s%s" % (dt_format, ms_format, tz_format)
def iso8601_format_now(milliseconds: bool=False) -> str:
- return iso8601_format(datetime_utcnow(), milliseconds=milliseconds)
+ return iso8601_format(utcnow(), milliseconds=milliseconds)
def iso8601_parse(s: str, microseconds: bool=False) -> _datetime.datetime:
fmt = ISO8601_PARSE_MICROSECONDS if microseconds else ISO8601_PARSE
return _datetime.datetime.strptime(s, fmt)