diff options
| author | 2020-01-30 21:21:12 +0000 | |
|---|---|---|
| committer | 2020-01-30 21:21:12 +0000 | |
| commit | 5d3e1ea49247b9e55406002a326445d8eb55345f (patch) | |
| tree | 4be1e9817d4302da24f0457ac09c782ddc0003b6 /src/utils/parse | |
| parent | split utils.datetime out in to .parse and .format (diff) | |
| signature | ||
add 'date' command spec type
Diffstat (limited to 'src/utils/parse')
| -rw-r--r-- | src/utils/parse/spec.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/utils/parse/spec.py b/src/utils/parse/spec.py index 4e30c294..1aa24610 100644 --- a/src/utils/parse/spec.py +++ b/src/utils/parse/spec.py @@ -1,6 +1,7 @@ import enum, typing from .time import duration from .types import try_int +from src.utils.datetime.parse import date_human class SpecArgumentContext(enum.IntFlag): CHANNEL = 1 @@ -67,6 +68,14 @@ class SpecArgumentTypeDuration(SpecArgumentType): def error(self) -> typing.Optional[str]: return "Invalid timeframe" +class SpecArgumentTypeDate(SpecArgumentType): + def name(self): + return SpecArgumentType.name(self) or "yyyy-mm-dd" + def simple(self, args): + if args: + return date_human(args[0], 1) + return None, 1 + class SpecArgumentPrivateType(SpecArgumentType): context = SpecArgumentContext.PRIVATE @@ -77,6 +86,7 @@ SPEC_ARGUMENT_TYPES = { "string": SpecArgumentTypeString, "tstring": SpecArgumentTypeTrimString, "int": SpecArgumentTypeInt, + "date": SpecArgumentTypeDate, "duration": SpecArgumentTypeDuration } |
