Time Module
Custom date/time input handlers for Parameters.
Warning
Uses locale.setlocale()
if alternate locales are specified, which may cause problems on some systems.
Using alternate locales in this manner should not be used in a multi-threaded application, as it will lead to
unexpected output from other parts of the program.
If you need to handle multiple locales and this is a problem for your application, then you should leave the
locale
parameters empty / None
and use a proper i18n library like babel
for localization.
- author:
Doug Skrypa
- class cli_command_parser.inputs.time.different_locale(locale: str | Tuple[str | None, str | None] | None)[source]
Bases:
object
Context manager that allows the temporary use of an alternate locale for date/time parsing/formatting.
Not using
python:calendar.different_locale
because it results in incorrect string encoding for some locales (at least on Windows).- locale
- original
- class cli_command_parser.inputs.time.DTInput(locale: str | Tuple[str | None, str | None] = None, fix_default: bool | Any = True)[source]
- class cli_command_parser.inputs.time.DTFormatMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
MissingMixin
,Enum
- FULL = 'full'
The full name of a given date/time unit
- ABBREVIATION = 'abbreviation'
The abbreviation of a given date/time unit
- NUMERIC = 'numeric'
The numeric representation of a given date/time unit
- NUMERIC_ISO = 'numeric_iso'
The ISO numeric representation of a given date/time unit
- class cli_command_parser.inputs.time.CalendarUnitInput(*, full: bool | Any = True, abbreviation: bool | Any = True, numeric: bool | Any = False, locale: str | Tuple[str | None, str | None] = None, out_format: str | DTFormatMode = DTFormatMode.FULL, out_locale: str | Tuple[str | None, str | None] = None, fix_default: bool | Any = True)[source]
Bases:
DTInput
[str
|int
],ABC
- full
- abbreviation
- numeric
- out_format
- out_locale
- class cli_command_parser.inputs.time.Day(*, full: bool | Any = True, abbreviation: bool | Any = True, numeric: bool | Any = False, iso: bool | Any = False, locale: str | Tuple[str | None, str | None] = None, out_format: str | DTFormatMode = DTFormatMode.FULL, out_locale: str | Tuple[str | None, str | None] = None, fix_default: bool | Any = True)[source]
Bases:
CalendarUnitInput
- iso
- class cli_command_parser.inputs.time.Month(*, full: bool | Any = True, abbreviation: bool | Any = True, numeric: bool | Any = True, locale: str | Tuple[str | None, str | None] = None, out_format: str | DTFormatMode = DTFormatMode.FULL, out_locale: str | Tuple[str | None, str | None] = None, fix_default: bool | Any = True)[source]
Bases:
CalendarUnitInput
- class cli_command_parser.inputs.time.TimeDelta(unit: Literal['microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', 'days', 'weeks'], *, min: NT | None = None, max: NT | None = None, include_min: bool | Any = True, include_max: bool | Any = False, int_only: bool | Any = False, fix_default: bool | Any = True)[source]
Bases:
RangeMixin
,InputType
[timedelta
]- unit
- min: Number
- max: Number
- int_only
- class cli_command_parser.inputs.time.DateTimeInput(formats: Collection[str], locale: str | Tuple[str | None, str | None] = None, earliest: datetime | date | time | timedelta | None = None, latest: datetime | date | time | timedelta | None = None, fix_default: bool | Any = True)[source]
-
- formats: Collection[str]
- class cli_command_parser.inputs.time.DateTime(*formats: str, locale: str | Tuple[str | None, str | None] = None, earliest: datetime | date | time | timedelta | None = None, latest: datetime | date | time | timedelta | None = None, fix_default: bool | Any = True)[source]
Bases:
DateTimeInput
[datetime
]
- class cli_command_parser.inputs.time.Date(*formats: str, locale: str | Tuple[str | None, str | None] = None, earliest: datetime | date | time | timedelta | None = None, latest: datetime | date | time | timedelta | None = None, fix_default: bool | Any = True)[source]
Bases:
DateTimeInput
[date
]
- class cli_command_parser.inputs.time.Time(*formats: str, locale: str | Tuple[str | None, str | None] = None, earliest: datetime | date | time | timedelta | None = None, latest: datetime | date | time | timedelta | None = None, fix_default: bool | Any = True)[source]
Bases:
DateTimeInput
[time
]