mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipalib: Add DateTime parameter
Adds a parameter that represents a DateTime format using datetime.datetime
object from python's native datetime library.
In the CLI, accepts one of the following formats:
Accepts LDAP Generalized time without in the following format:
'%Y%m%d%H%M%SZ'
Accepts subset of values defined by ISO 8601:
'%Y-%m-%dT%H:%M:%SZ'
'%Y-%m-%dT%H:%MZ'
'%Y-%m-%dZ'
Also accepts above formats using ' ' (space) as a separator instead of 'T'.
As a simplification, it does not deal with timezone info and ISO 8601
values with timezone info (+-hhmm) are rejected. Values are expected
to be in the UTC timezone.
Values are saved to LDAP as LDAP Generalized time values in the format
'%Y%m%d%H%SZ' (no time fractions and UTC timezone is assumed). To avoid
confusion, in addition to subset of ISO 8601 values, the LDAP generalized
time in the format '%Y%m%d%H%M%SZ' is also accepted as an input (as this is the
format user will see on the output).
Part of: https://fedorahosted.org/freeipa/ticket/3306
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
committed by
Alexander Bokovoy
parent
093c72d60e
commit
1df696f543
@@ -46,11 +46,13 @@ import plugable
|
||||
from errors import (PublicError, CommandError, HelpError, InternalError,
|
||||
NoSuchNamespaceError, ValidationError, NotFound,
|
||||
NotConfiguredError, PromptFailed)
|
||||
from constants import CLI_TAB
|
||||
from constants import CLI_TAB, LDAP_GENERALIZED_TIME_FORMAT
|
||||
from parameters import File, Str, Enum, Any
|
||||
from text import _
|
||||
from ipapython.version import API_VERSION
|
||||
|
||||
import datetime
|
||||
|
||||
|
||||
def to_cli(name):
|
||||
"""
|
||||
@@ -155,6 +157,8 @@ class textui(backend.Backend):
|
||||
"""
|
||||
if type(value) is str:
|
||||
return base64.b64encode(value)
|
||||
elif type(value) is datetime.datetime:
|
||||
return value.strftime(LDAP_GENERALIZED_TIME_FORMAT)
|
||||
else:
|
||||
return value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user