Retourne la date courante ou depuis l'argument au format datetime

		:param: :date_from date de référence
		:return datetime
16322
def convert(self, date_from=None, date_format=None):
		
		try:
			if date_format is None:
				# on détermine la date avec dateutil
				return dateutil.parser.parse(date_from)

			# il y a un format de date prédéfini
			return datetime.strptime(date_from, date_format)

		except:
			# échec, on prend la date courante
			return datetime.now()
712549
def dt_from_header(date_str):
    
    convert_fns = (
        dt_from_rfc8601,
        dt_from_rfc1123,
    )

    for convert_fn in convert_fns:
        try:
            return convert_fn(date_str)
        except ValueError:
            pass

    return None
249338
function since(date) {
  if (typeof date !== 'object') {
    return date
  } else if (date.getTime) {
    return Math.floor(date.getTime() / 1000)
  }
  throw TypeError('Expected a date or number')
}
907836
def date(objet):
        
        if objet:
            return "{}/{}/{}".format(objet.day, objet.month, objet.year)
        return ""
809003
def _datetime_to_date(arg):
    
    _arg = parse(arg)
    if isinstance(_arg, datetime.datetime):
        _arg = _arg.date()
    return _arg
1130145
def date(ctx, year, month, day):
    
    return _date(conversions.to_integer(year, ctx), conversions.to_integer(month, ctx), conversions.to_integer(day, ctx))
700209
def date(anon, obj, field, val):
    
    return anon.faker.date(field=field)
763055
def date_fromnow(self, value):
        
        import humanize
        language = self.get_language()
        if language != 'en':
            humanize.i18n.activate(language)
        return Markup(humanize.naturaltime(value))
732236
def _date_to_datetime(value):
  
  if not isinstance(value, datetime.date):
    raise TypeError('Cannot convert to datetime expected date value; '
                    'received %s' % value)
  return datetime.datetime(value.year, value.month, value.day)
715994
def format_iso_datetime(datetime_obj):
    
    datetime_obj = localize_datetime(datetime_obj, pytz.utc)
    if datetime_obj < MIN_DATE:
        datetime_obj = MIN_DATE
    elif datetime_obj > MAX_DATE:
        datetime_obj = MAX_DATE
    return datetime_obj.replace(tzinfo=None).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
773988
def to_date(value, default=None):
    
    if isinstance(value, DateTime):
        return value
    if not value:
        if default is None:
            return None
        return to_date(default)
    try:
        if isinstance(value, str) and '.' in value:
            # https://docs.plone.org/develop/plone/misc/datetime.html#datetime-problems-and-pitfalls
            return DateTime(value, datefmt='international')
        return DateTime(value)
    except:
        return to_date(default)
700394
def str_to_date(date: str) -> datetime.datetime:
    
    date = date.split('.')
    date.reverse()
    y, m, d = date
    return datetime.datetime(int(y), int(m), int(d))
660449
def cleaned_date(day, keep_datetime=False):
    
    if not isinstance(day, (date, datetime)):
        raise UnsupportedDateType(
            "`{}` is of unsupported type ({})".format(day, type(day)))
    if not keep_datetime:
        if hasattr(day, 'date') and callable(day.date):
            day = day.date()
    return day
1113065
def relative_date_to_date(p_date, p_offset=None):
    
    result = None
    p_date = p_date.lower()
    p_offset = p_offset or date.today()

    relative = re.match('(?P<length>-?[0-9]+)(?P<period>[dwmyb])$',
                        p_date, re.I)

    monday = 'mo(n(day)?)?$'
    tuesday = 'tu(e(sday)?)?$'
    wednesday = 'we(d(nesday)?)?$'
    thursday = 'th(u(rsday)?)?$'
    friday = 'fr(i(day)?)?$'
    saturday = 'sa(t(urday)?)?$'
    sunday = 'su(n(day)?)?$'

    weekday = re.match('|'.join(
        [monday, tuesday, wednesday, thursday, friday, saturday, sunday]),
        p_date)

    if relative:
        length = relative.group('length')
        period = relative.group('period')
        result = _convert_pattern(length, period, p_offset)

    elif weekday:
        result = _convert_weekday_pattern(weekday.group(0))

    elif re.match('tod(ay)?$', p_date):
        result = _convert_pattern('0', 'd')

    elif re.match('tom(orrow)?$', p_date):
        result = _convert_pattern('1', 'd')

    elif re.match('yes(terday)?$', p_date):
        result = _convert_pattern('-1', 'd')

    return result
1325239
def int_to_date(date):
    

    year = date // 10**4
    month = date % 10**4 // 10**2
    day = date % 10**2

    return datetime.date(year, month, day)
896284
def weekend_yesterday(self, date_from=None, date_format=None):
		
		# date d'hier que sur les jours de week-end
		return self.delta(days=-1, date_from=date_from, date_format=date_format, days_range=[6, 7])
1042638
def set!(date)
      date = Date.parse date if date.is_a?(String)

      message = "DateField##{__callee__} only accepts instances of Date or Time"
      raise ArgumentError, message unless [Date, ::Time].include?(date.class)

      date_string = date.strftime('%Y-%m-%d')
      element_call(:wait_for_writable) { execute_js(:setValue, @element, date_string) }
    end