Example #1
0
 def value_from_datadict(self, data, files, name):
     try:
         D = to_current_timezone(datetime.strptime(data[name], self.format))
     except ValueError:
         return ''
     else:
         return D
    def decompress(self, value):

        if self.is_localized:
            # Adapt the format to the user.
            self.to_local()

        if value:
            value = to_current_timezone(value).strftime(self.format)
            return (value,)
        return (None,)
 def value_from_datadict(self, data, files, name):
     date_time = [
     widget.value_from_datadict(data, files, name + '_%s' % i)
     for i, widget in enumerate(self.widgets)]
     try:
         D  = to_current_timezone(datetime.strptime(date_time[0], self.format))
     except ValueError:
         return ''
     else:
         return str(D)
 def decompress(self, value):
     if value:
         value = to_current_timezone(value)
         d = strftime("%Y-%m-%d", value.timetuple())
         hour = strftime("%I", value.timetuple())
         minute = strftime("%M", value.timetuple())
         meridian = strftime("%p", value.timetuple())
         return (d, hour, minute, meridian)
     else:
         return (None, None, None, None)
Example #5
0
    def value_from_datadict(self, data, files, name):

        if self.is_localized:
            #Adapt the format to the user.
            self.to_local()

        date_time = [
            widget.value_from_datadict(data, files, name + '_%s' % i)
            for i, widget in enumerate(self.widgets)
        ]
        try:
            D = to_current_timezone(datetime.strptime(date_time[0], self.format))
        except (ValueError, TypeError), e:
            return ''
 def decompress(self, value):
     if value:
         value = to_current_timezone(value)
         return (value,)
     return (None,)