diff options
| author | 2021-12-01 14:44:00 -0500 | |
|---|---|---|
| committer | 2021-12-01 14:44:00 -0500 | |
| commit | a5aecc343fd2886e7ae09bb3e2afeec38f175755 (patch) | |
| tree | 06a284b3d73700bd38116423e2480afa516255c2 /gallery_dl/formatter.py | |
| parent | fc8c5e642017e2b4e5299e2093e72b316479690d (diff) | |
New upstream version 1.19.3.upstream/1.19.3
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) |
