diff options
| author | 2019-06-19 11:06:26 +0100 | |
|---|---|---|
| committer | 2019-06-19 11:06:26 +0100 | |
| commit | 9407e083bd336711cc9aae3deb49c03beb1b00a4 (patch) | |
| tree | 00631d6acb263c93da44f60f855cfcee83b5e8ae /modules/birthday.py | |
| parent | add `margin` arg to ParsedLine.truncate so commands/outs.py doesn't do it (diff) | |
| signature | ||
Manually strf birthdays so years are not .strip("0")ed
Diffstat (limited to 'modules/birthday.py')
| -rw-r--r-- | modules/birthday.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/birthday.py b/modules/birthday.py index 173ccaf3..46a1dde6 100644 --- a/modules/birthday.py +++ b/modules/birthday.py @@ -18,9 +18,18 @@ def _parse(s): return True, datetime.datetime.strptime(s, DATE_YEAR_FORMAT) except ValueError: return None + +def _format_year(dt): + return "%s-%s-%s" % (str(dt.year).zfill(4), str(dt.month).zfill(2), + str(dt.day).zfill(2)) +def _format_noyear(dt): + return datetime.datetime.strftime(dt, DATE_FORMAT) + def _format(years, dt): - return datetime.datetime.strftime(dt, - DATE_YEAR_FORMAT if years else DATE_FORMAT) + if years: + return _format_year(dt) + else: + return _format_noyear(dt) def _check(s): parsed = _parse(s) if parsed: |
