aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar jesopo2019-11-25 18:18:09 +0000
committerGravatar jesopo2019-11-25 18:18:09 +0000
commit93aea08818252dd65a02a31894bfeea9fc0e45b9 (patch)
tree2de12f1bb644bd37c90c8f7d151b7a5b715ff7aa /src
parentadd `cookies` and `.json()` to utils.http.Response objects (diff)
signature
utils.datetime.datetime_utcnow() -> utils.datetime.utcnow()
Diffstat (limited to 'src')
-rw-r--r--src/LockFile.py6
-rw-r--r--src/utils/datetime.py4
2 files changed, 5 insertions, 5 deletions
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)