我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wtforms.fields.DateTimeField()。
def conv_DateTime(self, field_args, **extra): return f.DateTimeField(**field_args)
def __init__(self, *args, **kwargs): if not has_timezone: raise ImportError('DateTimeField requires Django >= 1.5') super(DateTimeField, self).__init__(*args, **kwargs)
def process_formdata(self, valuelist): super(DateTimeField, self).process_formdata(valuelist) date = self.data if settings.USE_TZ and date is not None and timezone.is_naive(date): current_timezone = timezone.get_current_timezone() self.data = timezone.make_aware(date, current_timezone)
def _value(self): date = self.data if settings.USE_TZ and isinstance(date, datetime.datetime) and timezone.is_aware(date): self.data = timezone.localtime(date) return super(DateTimeField, self)._value()
def conv_TimeField(self, model, field, kwargs): def time_only(obj): try: return obj.time() except AttributeError: return obj kwargs['filters'].append(time_only) return f.DateTimeField(format='%H:%M:%S', **kwargs)
def convert_TimeProperty(model, prop, kwargs): """Returns a form field for a ``db.TimeProperty``.""" if prop.auto_now or prop.auto_now_add: return None kwargs.setdefault('format', '%H:%M:%S') return f.DateTimeField(**kwargs)
def convert_DateTimeProperty(self, model, prop, kwargs): """Returns a form field for a ``ndb.DateTimeProperty``.""" if prop._auto_now or prop._auto_now_add: return None return f.DateTimeField(format='%Y-%m-%d %H:%M:%S', **kwargs)
def convert_TimeProperty(self, model, prop, kwargs): """Returns a form field for a ``ndb.TimeProperty``.""" if prop._auto_now or prop._auto_now_add: return None return f.DateTimeField(format='%H:%M:%S', **kwargs)
def convert_DateTimeProperty(model, prop, kwargs): """Returns a form field for a ``db.DateTimeProperty``.""" if prop.auto_now or prop.auto_now_add: return None kwargs.setdefault('format', '%Y-%m-%d %H:%M:%S') return f.DateTimeField(**kwargs)