add utils.date_human() - use it in badges.py
This commit is contained in:
parent
2c1b838172
commit
3634b72622
2 changed files with 4 additions and 2 deletions
|
@ -6,7 +6,6 @@ from src import ModuleManager, utils
|
|||
RE_HUMAN_FORMAT = re.compile(r"(\d\d\d\d)-(\d?\d)-(\d?\d)")
|
||||
HUMAN_FORMAT_HELP = "year-month-day (e.g. 2018-12-29)"
|
||||
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||
DATE_FORMAT = "%Y-%m-%d"
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
def _parse_date(self, dt: str):
|
||||
|
@ -24,7 +23,7 @@ class Module(ModuleManager.BaseModule):
|
|||
).replace(tzinfo=datetime.timezone.utc)
|
||||
|
||||
def _date_str(self, dt: datetime.datetime):
|
||||
return datetime.datetime.strftime(dt, DATE_FORMAT)
|
||||
return utils.date_human(dt)
|
||||
|
||||
def _round_up_day(self, dt: datetime.datetime):
|
||||
return dt.date()+datetime.timedelta(days=1)
|
||||
|
|
|
@ -14,6 +14,7 @@ ISO8601_FORMAT_TZ = "%z"
|
|||
|
||||
|
||||
DATETIME_HUMAN = "%Y/%m/%d %H:%M:%S"
|
||||
DATE_HUMAN = "%Y-%m-%d"
|
||||
|
||||
def datetime_utcnow() -> datetime.datetime:
|
||||
return datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
|
||||
|
@ -35,6 +36,8 @@ def iso8601_parse(s: str, microseconds: bool=False) -> datetime.datetime:
|
|||
|
||||
def datetime_human(dt: datetime.datetime):
|
||||
return datetime.datetime.strftime(dt, DATETIME_HUMAN)
|
||||
def date_human(dt: datetime.datetime):
|
||||
return datetime.datetime.strftime(dt, DATE_HUMAN)
|
||||
|
||||
TIME_SECOND = 1
|
||||
TIME_MINUTE = TIME_SECOND*60
|
||||
|
|
Loading…
Reference in a new issue