mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
ad28291208
commit
b4142e9de4
|
@ -23,7 +23,7 @@ from session import postJson
|
|||
from session import postImage
|
||||
from session import createSession
|
||||
from utils import has_object_stringType
|
||||
from utils import dateStringToSeconds
|
||||
from utils import date_string_to_seconds
|
||||
from utils import date_seconds_to_string
|
||||
from utils import get_config_param
|
||||
from utils import get_full_domain
|
||||
|
@ -1787,10 +1787,10 @@ def _dfcToSharesFormat(catalogJson: {},
|
|||
if ':' not in item['DFC:hasType']:
|
||||
continue
|
||||
|
||||
startTimeSec = dateStringToSeconds(item['DFC:startDate'])
|
||||
startTimeSec = date_string_to_seconds(item['DFC:startDate'])
|
||||
if not startTimeSec:
|
||||
continue
|
||||
expiryTimeSec = dateStringToSeconds(item['DFC:expiryDate'])
|
||||
expiryTimeSec = date_string_to_seconds(item['DFC:expiryDate'])
|
||||
if not expiryTimeSec:
|
||||
continue
|
||||
if expiryTimeSec < curr_time:
|
||||
|
|
4
tests.py
4
tests.py
|
@ -63,7 +63,7 @@ from utils import get_category_types
|
|||
from utils import get_supported_languages
|
||||
from utils import setConfigParam
|
||||
from utils import is_group_actor
|
||||
from utils import dateStringToSeconds
|
||||
from utils import date_string_to_seconds
|
||||
from utils import date_seconds_to_string
|
||||
from utils import validPassword
|
||||
from utils import userAgentDomain
|
||||
|
@ -5674,7 +5674,7 @@ def _testAuthorizeSharedItems():
|
|||
def _testDateConversions() -> None:
|
||||
print('testDateConversions')
|
||||
dateStr = "2021-05-16T14:37:41Z"
|
||||
dateSec = dateStringToSeconds(dateStr)
|
||||
dateSec = date_string_to_seconds(dateStr)
|
||||
dateStr2 = date_seconds_to_string(dateSec)
|
||||
assert dateStr == dateStr2
|
||||
|
||||
|
|
11
utils.py
11
utils.py
|
@ -2969,16 +2969,17 @@ def isfloat(value):
|
|||
return False
|
||||
|
||||
|
||||
def dateStringToSeconds(dateStr: str) -> int:
|
||||
def date_string_to_seconds(date_str: str) -> int:
|
||||
"""Converts a date string (eg "published") into seconds since epoch
|
||||
"""
|
||||
try:
|
||||
expiryTime = \
|
||||
datetime.datetime.strptime(dateStr, '%Y-%m-%dT%H:%M:%SZ')
|
||||
expiry_time = \
|
||||
datetime.datetime.strptime(date_str, '%Y-%m-%dT%H:%M:%SZ')
|
||||
except BaseException:
|
||||
print('EX: dateStringToSeconds unable to parse date ' + str(dateStr))
|
||||
print('EX: date_string_to_seconds unable to parse date ' +
|
||||
str(date_str))
|
||||
return None
|
||||
return int(datetime.datetime.timestamp(expiryTime))
|
||||
return int(datetime.datetime.timestamp(expiry_time))
|
||||
|
||||
|
||||
def date_seconds_to_string(date_sec: int) -> str:
|
||||
|
|
Loading…
Reference in New Issue