State for handling dateto:foo constructs. Potentially emits a token.
532
function indateto($content){
        if (strlen($content) < 8) { // State exit or missing parameter.
            return true;
        }
        // Strip off the dateto: part and add the reminder to the parsed token array
        $param = trim(substr($content,7));
        $this->tokens[] = new search_token(TOKEN_DATETO,$param);
        return true;
    }
1234170
function encodeDate(date) {
	if (!(date instanceof Date)) throw new Error('Value not Date: ' + date)
	return (date.getUTCFullYear() * monthsPerYear + date.getUTCMonth()) - yearMonthZero
}
102767
function(value) {
        switch (typeof value) {
            case 'boolean':
                return 'Boolean';

            case 'number':
                return 'Number';

            case 'string':
                return 'String';

            case 'object':
                if (value === null) {
                    return 'Null';
                } else {
                    switch (Object.prototype.toString.call(value)) {
                        case '[object RegExp]':
                            return 'RegExp';

                        case '[object Array]':
                            return 'Array';

                        case '[object Object]':
                            switch (value.constructor) {
                                case JuttleMoment:
                                    if (value.moment) {
                                        return 'Date';
                                    }
                                    if (value.duration) {
                                        return 'Duration';
                                    }
                                    break;   // silence ESLint

                                case Filter:
                                    return 'Filter';

                                case Object:
                                    return 'Object';
                            }
                    }
                }
        }

        throw new Error('Invalid Juttle value: ' + value + '.');
    }
94390
def _parse_date(self, dt, fmt=None):
        
        try:
            # test if it's not a datelike instance ...
            _dt = utils.Date(dt, fmt=fmt)
        except ValueError:
            # nope, not a datelike instance
            _dt = None
        return _dt
763055
def date_fromnow(self, value):
        
        import humanize
        language = self.get_language()
        if language != 'en':
            humanize.i18n.activate(language)
        return Markup(humanize.naturaltime(value))
557613
def setcreated(self, dt=None):
        
        if dt is None:
            self.created = Token.utc()
        else:
            self.created = dt
891017
function(type, args, obj) {
        var val = args[0];
        if (Lang.isString(val)) {
            val = this._parseDate(val);
            this.cfg.setProperty(DEF_CFG.MINDATE.key, DateMath.getDate(val[0],(val[1]-1),val[2]));
        }
    }
1062634
def onOffset(self, date):
        """"""
        return date.day == _days_in_month(date) and date.month == self.month
236008
@Override  // override with covariant return type
    public MinguoDate date(TemporalAccessor temporal) {
        if (temporal instanceof MinguoDate) {
            return (MinguoDate) temporal;
        }
        return new MinguoDate(LocalDate.from(temporal));
    }
1242947
def datetime_handler(x):
    
    if isinstance(x, datetime.datetime) or isinstance(x, datetime.date):
        return x.isoformat()
    raise TypeError("Unknown type")
1290751
function(date) {
        var tooEarly = this.minDate && date < this.minDate,
            tooLate = this.maxDate && date > this.maxDate;

        if (this.method == 'between') {
            if (tooEarly)
                return true;
            if (tooLate)
                return false;
        } else if (this.method == 'before') {
            if (tooLate)
                return false;
        } else if (this.method == 'after') {
            if (tooEarly)
                return true;
            this.add(date);
            return false;
        }

        return this.add(date);

    }
188585
def _serialize_date(value):
    """"""
    if not isinstance(value, date):
        raise ValueError(u'The received object was not a date: '
                         u'{} {}'.format(type(value), value))
    return value.isoformat()
143361
function (val) {
		var parseDate = this.options.parseDate,
			ret,
			key,
			format,
			dateFormat = this.options.dateFormat || this.dateFormat,
			match;

		if (parseDate) {
			ret = parseDate(val);
		
		} else if (typeof val === 'string') {
			// Auto-detect the date format the first time
			if (!dateFormat) {
				for (key in this.dateFormats) {
					format = this.dateFormats[key];
					match = val.match(format.regex);
					if (match) {
						this.dateFormat = dateFormat = key;
						this.alternativeFormat = format.alternative;
						ret = format.parser(match);
						break;
					}
				}
			// Next time, use the one previously found
			} else {
				format = this.dateFormats[dateFormat];
				match = val.match(format.regex);
				if (match) {
					ret = format.parser(match);
				}
			}
			// Fall back to Date.parse		
			if (!match) {
				match = Date.parse(val);
				// External tools like Date.js and MooTools extend Date object and
				// returns a date.
				if (typeof match === 'object' && match !== null && match.getTime) {
					ret = match.getTime() - match.getTimezoneOffset() * 60000;
				
				// Timestamp
				} else if (typeof match === 'number' && !isNaN(match)) {
					ret = match - (new Date(match)).getTimezoneOffset() * 60000;
				}
			}
		}
		return ret;
	}
345673
def todate(val):
    '''
    '''
    if not val:
        raise ValueError("Value not provided")
    if isinstance(val, datetime):
        return val.date()
    elif isinstance(val, date):
        return val
    else:
        try:
            ival = int(val)
            sval = str(ival)
            if len(sval) == 8:
                return yyyymmdd2date(val)
            elif len(sval) == 5:
                return juldate2date(val)
            else:
                raise ValueError
        except Exception:
            # Try to convert using the parsing algorithm
            try:
                return date_from_string(val).date()
            except Exception:
                raise ValueError("Could not convert %s to date" % val)
1356861
def on_post(self, req, resp):
        """"""
        args = req.context["args"]
        value = args["value"] or dt.datetime.utcnow()
        if args["unit"] == "minutes":
            delta = dt.timedelta(minutes=args["addend"])
        else:
            delta = dt.timedelta(days=args["addend"])
        result = value + delta
        req.context["result"] = {"result": result.isoformat()}
68038
def evolve(self, new_date):
        
        if self.state.date == new_date and not self.initial_state.date == new_date:
            return self.state
        self.state.value = self.func(self.state, new_date)
        self.state.date = new_date
        return self.state
853143
function gitDateOf(val) {
  let date = null;

  try {
    date = exec(`git log -1 --format=%cI ${val}`).toString();
  } catch (err) {
    return new Error(err);
  }

  return date.substring(0, date.indexOf('T'));
}