Return a new datetime.datetime object with values that represent
    a start of a day.
    :param val: Date to ...
    :type val: datetime.datetime | datetime.date
    :rtype: datetime.datetime
175563
def start_of_day(val):
    
    if type(val) == date:
        val = datetime.fromordinal(val.toordinal())
    return val.replace(hour=0, minute=0, second=0, microsecond=0)
685895
def caleom(date):
        
        date = parsefun(date)
        date += datetime.timedelta(days=32-date.day)
        date -= datetime.timedelta(days=date.day)
        return date
84625
def date(self, value=None):
        
        if not (value is None):
            if (self.metadatatype == "native"):
                self.metadata['date'] = value
            else:
                self._date = value
        if (self.metadatatype == "native"):
            if 'date' in self.metadata:
                return self.metadata['date']
            else:
                return None
        else:
            return self._date
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)
635467
def to_daydate(cls, *argv):
        
        argc = len(argv)
        if argc == 3:
            year, month, day = argv
        elif argc == 1:
            dval = argv[0]
            try:
                year = dval.year
                month = dval.month
                day = dval.day
            except AttributeError:
                raise InterfaceError("Unsupported python date input: %s (%s)" % (str(dval), dval.__class__))
        else:
            raise InterfaceError("Date.to_datetime does not support %d arguments." % argc)

        TURN_OF_ERAS = 1721424

        if month < 3:
            year -= 1
            month += 12

        if ((year > 1582) or
                (year == 1582 and month > 10) or
                (year == 1582 and month == 10 and day >= 15)):
            A = int(year / 100)
            B = int(A / 4)
            C = 2 - A + B
        else:
            C = 0

        E = int(365.25 * (year + 4716))
        F = int(30.6001 * (month + 1))
        Z = C + day + E + F - 1524
        return Z + 1 - TURN_OF_ERAS
152767
function(d, val) {
    var m = later.m.val(d),
        s = later.s.val(d),
        inc = val > 59 ? 60-m : (val <= m ? (60-m) + val : val-m),
        next = new Date(d.getTime() + (inc * later.MIN) - (s * later.SEC));

    // correct for passing over a daylight savings boundry
    if(!later.date.isUTC && next.getTime() <= d.getTime()) {
      next = new Date(d.getTime() + ((inc + 120) * later.MIN) - (s * later.SEC));
    }

    return next;
  }
623279
public static Date fromISODateTime(final String val,
                                     final TimeZone tz) throws BadDateException {
    try {
      synchronized (isoDateTimeTZFormat) {
        isoDateTimeTZFormat.setTimeZone(tz);
        return isoDateTimeTZFormat.parse(val);
      }
    } catch (Throwable t) {
      throw new BadDateException();
    }
  }
281883
def parse_datetime(value):
    
    if not value:
        return None
    elif isinstance(value, datetime.datetime):
        return value
    return dateutil.parser.parse(value)
45221
public static Date fromISODateTime(final String val) throws BadDateException {
    try {
      synchronized (isoDateTimeFormat) {
        try {
          isoDateTimeFormat.setTimeZone(Timezones.getDefaultTz());
        } catch (TimezonesException tze) {
          throw new RuntimeException(tze);
        }
        return isoDateTimeFormat.parse(val);
      }
    } catch (Throwable t) {
      throw new BadDateException();
    }
  }
398890
def calendar_dates(self, val):
        
        self._calendar_dates = val
        if val is not None and not val.empty:
            self._calendar_dates_g = self._calendar_dates.groupby(
                ["service_id", "date"]
            )
        else:
            self._calendar_dates_g = None
927870
def start_of_month(val):
    
    if type(val) == date:
        val = datetime.fromordinal(val.toordinal())
    return start_of_day(val).replace(day=1)
1327402
def new_start(start = Date::ITALY)
      if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) }
    end
924928
def naturaltime(val):
    """"""
    val = val.replace(tzinfo=pytz.utc) \
        if isinstance(val, datetime) else parse(val)
    now = datetime.utcnow().replace(tzinfo=pytz.utc)

    return humanize.naturaltime(now - val)
1018745
public static boolean isISODateTime(final String val) throws BadDateException {
    try {
      if (val.length() != 15) {
        return false;
      }
      fromISODateTime(val);
      return true;
    } catch (Throwable t) {
      return false;
    }
  }
799388
def parse_date(value):
    
    if not value:
        return None

    if isinstance(value, datetime.date):
        return value

    return parse_datetime(value).date()
575104
def begin_date(self, value):
        

        if not isinstance(value, datetime):
            raise TypeError(_pretty_message(
                '''
                begin_date must be an instance of datetime.datetime, not %s
                ''',
                _type_name(value)
            ))

        self._begin_date = value
534326
def before_start(self, when=None):
        
        if when is None:
            when = datetime.now()

        return self._val[0] > when