diff options
Diffstat (limited to 'gallery_dl/formatter.py')
| -rw-r--r-- | gallery_dl/formatter.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gallery_dl/formatter.py b/gallery_dl/formatter.py index f5d961a..c2b4d99 100644 --- a/gallery_dl/formatter.py +++ b/gallery_dl/formatter.py @@ -274,6 +274,8 @@ def build_format_func(format_spec): return _parse_join(format_spec) if fmt == "R": return _parse_replace(format_spec) + if fmt == "D": + return _parse_datetime(format_spec) return _default_format(format_spec) return format @@ -319,6 +321,16 @@ def _parse_replace(format_spec): return replace +def _parse_datetime(format_spec): + dt_format, _, format_spec = format_spec.partition("/") + dt_format = dt_format[1:] + fmt = build_format_func(format_spec) + + def dt(obj): + return fmt(text.parse_datetime(obj, dt_format)) + return dt + + def _default_format(format_spec): def wrap(obj): return format(obj, format_spec) |
