Display a date range in the shorter possible maner.
496760
def daterange(value, details=False):
    ''''''
    if not isinstance(value, db.DateRange):
        raise ValueError('daterange only accept db.DateRange as parameter')

    if details:
        return daterange_with_details(value)

    date_format = 'YYYY'

    delta = value.end - value.start
    start, end = None, None
    start = format_date(value.start, date_format)
    if delta.days > 365:
        end = format_date(value.end, date_format)

    return '{start!s}–{end!s}'.format(start=start, end=end) if end else start
1240190
function(inst, date) {
		var minDate = this._getMinMaxDate(inst, "min"),
			maxDate = this._getMinMaxDate(inst, "max"),
			newDate = (minDate && date < minDate ? minDate : date);
		return (maxDate && newDate > maxDate ? maxDate : newDate);
	}
1042871
def displayName(date, options=None, format='%b %d, %Y'):
    
    # map from Qt information
    if type(date).__name__ in ('QDate', 'QDateTime', 'QTime'):
        date = date.toPython()

    if isinstance(date, datetime.datetime):
        time = ' @ ' + date.strftime('%I:%M%p').strip('0M').lower()
        date = date.date()
    else:
        time = ''

    today = datetime.date.today()
    delta = date - today

    if delta.days == 0:
        return 'Today' + time
    elif delta.days == -1:
        return 'Yesterday' + time
    elif delta.days == 1:
        return 'Tomorrow' + time
    elif abs(delta.days) < 8:
        # look for different weeks
        if date.isocalendar()[1] != today.isocalendar()[1]:
            qualifier = 'Last ' if delta.days < 0 else 'Next '
        else:
            qualifier = ''

        return qualifier + date.strftime('%A') + time
    else:
        return date.strftime(format)
723449
def date_range(start_date, end_date, increment, period):
    
    next = start_date
    delta = relativedelta.relativedelta(**{period:increment})
    while next <= end_date:
        yield next
        next += delta
1028608
def by_date(self, chamber, date):
        ""
        date = parse_date(date)
        return self.by_range(chamber, date, date)
578078
def display(self):
        """"""
        if self.degree and self.school:
            disp = self.degree + u' from ' + self.school
        else:
            disp = self.degree or self.school or None
        if disp is not None and self.date_range is not None:
            disp += u' (%d-%d)' % self.date_range.years_range
        return disp or u''
860644
def daterange_end(value):
    ''''''
    if not value:
        return None
    elif isinstance(value, datetime):
        return value.date()
    elif isinstance(value, date):
        return value

    result = parse_dt(value).date()
    dashes = value.count('-')

    if dashes >= 2:
        # Full date
        return result
    elif dashes == 1:
        # Year/Month
        return result + relativedelta(months=+1, days=-1, day=1)
    else:
        # Year only
        return result.replace(month=12, day=31)
21822
public static String writeShort(Date value) {
		if (value==null) return null;
		String text = ThreadLocalDateFormatter.format(value, SHORT);
		return text;
	}
958272
def update_datetime(value, range = None):
        
        range = range if range != None else 10
        if range < 0:
            return value
        
        days = RandomFloat.next_float(-range, range)

        return value + datetime.timedelta(days)
538818
def _min(self):
        """"""
        return (
            self.range[0] if (self.range and self.range[0] is not None) else
            (min(self.yvals) if self.yvals else None)
        )
575150
def preview(self, when=timezone.now(), **kwargs):
        """"""

        return self.operate_on(when=when, apply=False, **kwargs)
708690
def daterange_start(value):
    ''''''
    if not value:
        return None
    elif isinstance(value, datetime):
        return value.date()
    elif isinstance(value, date):
        return value

    result = parse_dt(value).date()
    dashes = value.count('-')

    if dashes >= 2:
        return result
    elif dashes == 1:
        # Year/Month only
        return result.replace(day=1)
    else:
        # Year only
        return result.replace(day=1, month=1)
188356
def check_in_bounds(self, date):
        '''
        '''
        dt = Timestamp(date)
        return ((self._lbound is None or dt >= self._lbound) and
                (self._rbound is None or dt <= self._rbound))
114380
def calculeToday(self):
        """"""
        self.__logger.debug("Add today")
        last = datetime.datetime.strptime(self.__lastDay, "%Y-%m-%d")
        today = datetime.datetime.now().date()
        self.__validInterval(last, today)
422864
def dateDict(date, prefix = ""):
    """"""
    res = {}

    res[prefix+"a"] = date.strftime("%a")
    res[prefix+"A"] = date.strftime("%A")
    res[prefix+"b"] = date.strftime("%b")
    res[prefix+"B"] = date.strftime("%B")
    res[prefix+"c"] = date.strftime("%c")
    res[prefix+"d"] = date.strftime("%d")
    res[prefix+"H"] = date.strftime("%H")
    res[prefix+"I"] = date.strftime("%I")
    res[prefix+"j"] = date.strftime("%j")
    res[prefix+"m"] = date.strftime("%m")
    res[prefix+"M"] = date.strftime("%M")
    res[prefix+"p"] = date.strftime("%p")
    res[prefix+"S"] = date.strftime("%S")
    res[prefix+"U"] = date.strftime("%U")
    res[prefix+"w"] = date.strftime("%w")
    res[prefix+"W"] = date.strftime("%W")
    res[prefix+"x"] = date.strftime("%x")
    res[prefix+"X"] = date.strftime("%X")
    res[prefix+"y"] = date.strftime("%y")
    res[prefix+"Y"] = date.strftime("%Y")
    res[prefix+"Z"] = date.strftime("%Z")

    for i, value in res.items():
        res[i] = locale_to_utf8(value)

    return res
1234146
static function convertDateRangeDefaultsToDates($in_type, $in_string, &$range_start, &$range_end)
    {
        $retval = true;
        if ($in_type == "DATE") {
            $elar = preg_split("/-/", $in_string);
            if (count($elar) == 1) {
                $range_start = $in_string;
            } else if (count($elar) == 3) // Specified in xx-xx-xx format
            {
                $range_start = $elar[0] . "-" . $elar[1] . "-" . $elar[2];
            } else {
                $retval = false;
                $range_start = "TODAY";
            }
        }

        if ($in_type == "DATERANGE") {
            $range_start = "TODAY";
            $range_end = "TODAY";
            $elar = preg_split("/-/", $in_string);

            if (count($elar) == 2) {
                $range_start = $elar[0];
                $range_end = $elar[1];
            } else if (count($elar) == 6) // Specified in xx-xx-xx format
            {
                $range_start = $elar[0] . "-" . $elar[1] . "-" . $elar[2];
                $range_end = $elar[3] . "-" . $elar[4] . "-" . $elar[5];
            } else if (count($elar) == 4 && is_numeric($elar[0]) && is_numeric($elar[1]) && is_numeric($elar[2]) && !is_numeric($elar[3])) // Specified in xx-xx-xx format
            {
                $range_start = $elar[0] . "-" . $elar[1] . "-" . $elar[2];
                $range_end = $elar[3];
            } else if (count($elar) == 4 && is_numeric($elar[1]) && is_numeric($elar[2]) && is_numeric($elar[3]) && !is_numeric($elar[0])) // Specified in xx-xx-xx format
            {
                $range_start = $elar[0];
                $range_end = $elar[1] . "-" . $elar[2] . "-" . $elar[3];
            } else {
                $retval = false;
                $range_start = "TODAY";
                $range_end = "TODAY";
            }
        }

        return $retval;
    }
793384
def check_valid_ad_range(date):
    
    if date < values.START_EN_DATE or date > values.END_EN_DATE:
        raise ValueError("Date out of range")
    return True