Parses a :py:class:`~luigi.date_interval.DateInterval` from the input.

        see :py:mod:`luigi.date_interval`
          for details on the parsing of DateIntervals.
971812
def parse(self, s):
        
        # TODO: can we use xml.utils.iso8601 or something similar?

        from luigi import date_interval as d

        for cls in [d.Year, d.Month, d.Week, d.Date, d.Custom]:
            i = cls.parse(s)
            if i:
                return i

        raise ValueError('Invalid date interval - could not be parsed')
1195715
def _parse(text, **options):
    
    # Handling special cases
    if text == "now":
        return pendulum.now()

    parsed = base_parse(text, **options)

    if isinstance(parsed, datetime.datetime):
        return pendulum.datetime(
            parsed.year,
            parsed.month,
            parsed.day,
            parsed.hour,
            parsed.minute,
            parsed.second,
            parsed.microsecond,
            tz=parsed.tzinfo or options.get("tz", UTC),
        )

    if isinstance(parsed, datetime.date):
        return pendulum.date(parsed.year, parsed.month, parsed.day)

    if isinstance(parsed, datetime.time):
        return pendulum.time(
            parsed.hour, parsed.minute, parsed.second, parsed.microsecond
        )

    if isinstance(parsed, _Interval):
        if parsed.duration is not None:
            duration = parsed.duration

            if parsed.start is not None:
                dt = pendulum.instance(parsed.start, tz=options.get("tz", UTC))

                return pendulum.period(
                    dt,
                    dt.add(
                        years=duration.years,
                        months=duration.months,
                        weeks=duration.weeks,
                        days=duration.remaining_days,
                        hours=duration.hours,
                        minutes=duration.minutes,
                        seconds=duration.remaining_seconds,
                        microseconds=duration.microseconds,
                    ),
                )

            dt = pendulum.instance(parsed.end, tz=options.get("tz", UTC))

            return pendulum.period(
                dt.subtract(
                    years=duration.years,
                    months=duration.months,
                    weeks=duration.weeks,
                    days=duration.remaining_days,
                    hours=duration.hours,
                    minutes=duration.minutes,
                    seconds=duration.remaining_seconds,
                    microseconds=duration.microseconds,
                ),
                dt,
            )

        return pendulum.period(
            pendulum.instance(parsed.start, tz=options.get("tz", UTC)),
            pendulum.instance(parsed.end, tz=options.get("tz", UTC)),
        )

    if CDuration and isinstance(parsed, CDuration):
        return pendulum.duration(
            years=parsed.years,
            months=parsed.months,
            weeks=parsed.weeks,
            days=parsed.days,
            hours=parsed.hours,
            minutes=parsed.minutes,
            seconds=parsed.seconds,
            microseconds=parsed.microseconds,
        )

    return parsed
1326732
def eval_interval(interval):
    
    kwargs = {
        "years": 0,
        "months": 0,
        "weeks": 0,
        "days": 0,
        "hours": 0,
        "minutes": 0,
        "seconds": 0,
        "microseconds": 0,
    }
    for section in interval[1:]:
        name = section.getName()
        if name == "year":
            kwargs["years"] += int(section[0])
        elif name == "month":
            kwargs["months"] += int(section[0])
        elif name == "week":
            kwargs["weeks"] += int(section[0])
        elif name == "day":
            kwargs["days"] += int(section[0])
        elif name == "hour":
            kwargs["hours"] += int(section[0])
        elif name == "minute":
            kwargs["minutes"] += int(section[0])
        elif name == "second":
            kwargs["seconds"] += int(section[0])
        elif name == "millisecond":
            kwargs["microseconds"] += 1000 * int(section[0])
        elif name == "microsecond":
            kwargs["microseconds"] += int(section[0])
        else:
            raise SyntaxError("Unrecognized interval type %r: %s" % (name, section))
    return relativedelta(**kwargs)
310491
function parseDoubleGroupedInterval(){
  var options = Array.prototype.slice.call(arguments);
  if (!options[0]) throw 'Requested parser requires a sequential list (array) of properties to target as a second argument';
  return function(res){
    var dataset = new Dataset()
      .type('double-grouped-interval');
    each(res.result, function(record, i){
      var index = options[1] && options[1] === 'timeframe.end' ? record.timeframe.end : record.timeframe.start;
      each(record['value'], function(value, j){
        var label = value[options[0][0]] + ' ' + value[options[0][1]];
        dataset.set([ label, index ], value.result);
      });
    });
    return dataset;
  }
}
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
79212
def reconstruct_interval(experiment_id):
    
    start, end = map(lambda x: udatetime.utcfromtimestamp(x / 1000.0), map(float, experiment_id.split("-")))
    from ..time_interval import TimeInterval
    return TimeInterval(start, end)
56326
def interval_timed(interval):
    '''
    '''
    def decorator(f):
        @wraps(f)
        def wrapper(*args, **kwargs):
            stopped = Event()

            def loop():  # executed in another thread
                while not stopped.wait(interval):  # until stopped
                    f(*args, **kwargs)

            t = Thread(name='IntervalTimerThread', target=loop)
            t.daemon = True  # stop if the program exits
            t.start()
            return stopped.set
        return wrapper
    return decorator
1087363
def parse(self):
        
        # Run the parser
        opt, arg = self.parser.parse_known_args(self.arguments)
        self.opt = opt
        self.arg = arg
        self.check()

        # Enable --all if no particular stat or group selected
        opt.all = not any([
            getattr(opt, stat.dest) or getattr(opt, group.dest)
            for group in self.sample_stats.stats
            for stat in group.stats])

        # Time period handling
        if opt.since is None and opt.until is None:
            opt.since, opt.until, period = did.base.Date.period(arg)
        else:
            opt.since = did.base.Date(opt.since or "1993-01-01")
            opt.until = did.base.Date(opt.until or "today")
            # Make the 'until' limit inclusive
            opt.until.date += delta(days=1)
            period = "given date range"

        # Validate the date range
        if not opt.since.date < opt.until.date:
            raise RuntimeError(
                "Invalid date range ({0} to {1})".format(
                    opt.since, opt.until.date - delta(days=1)))
        header = "Status report for {0} ({1} to {2}).".format(
            period, opt.since, opt.until.date - delta(days=1))

        # Finito
        log.debug("Gathered options:")
        log.debug('options = {0}'.format(opt))
        return opt, header
845979
def day_interval(year, month, day, return_str=False):
        
        start, end = datetime(year, month, day), datetime(year, month, day) + timedelta(days=1) - timedelta(seconds=1)
        if not return_str:
            return start, end
        else:
            return str(start), str(end)
16849
def set_interval(self, interval):
        
        if type(interval) != float or type(interval) != int:
            raise InvalidInput("Interval value must be of float or int")
        self._config['interval']
5002
public static DateInterval from(ChronoInterval<PlainDate> interval) {

        if (interval instanceof DateInterval) {
            return DateInterval.class.cast(interval);
        } else {
            return new DateInterval(interval.getStart(), interval.getEnd());
        }

    }
543385
def from_date(self, value: date) -> datetime:
        
        assert isinstance(value, date)

        #self.value = datetime.combine(value, time.min)
        self.value = datetime(value.year, value.month, value.day)
        return self.value
691764
def strptime_fuzzy(s):
    
    import dateutil.parser
    dt = dateutil.parser.parse(str(s), fuzzy=True) 
    return dt
1360575
def parse_date(self, value):
        
        if isinstance(value, sixmini.string_types):
            return self.str2date(value)
        elif value is None:
            raise TypeError("Unable to parse date from %r" % value)
        elif isinstance(value, sixmini.integer_types):
            return date.fromordinal(value)
        elif isinstance(value, datetime):
            return value.date()
        elif isinstance(value, date):
            return value
        else:
            raise ValueError("Unable to parse date from %r" % value)
696933
public static Interval parseInterval(String str) {
        String[] ss = str.split("-");

        Interval interval = new Interval();
        switch (ss.length) {
            case 1:
                interval.start = Long.parseLong(ss[0]);
                interval.stop = interval.start + 1;
                break;
            case 2:
                interval.start = Long.parseLong(ss[0]);
                interval.stop = Long.parseLong(ss[1]) + 1;
                break;
            default:
                throw new RuntimeException(String.format("parseInterval failed due to wrong format: %s", str));
        }

        return interval;
    }
309408
def from_date(cls, date):
        
        try:
            date = date.date()
        except AttributeError:
            pass
        return cls(date.year, date.month)
607700
def parseDate(dateString, strict=True):
    
    if (not strict) and (not dateString):
        return None

    if not isinstance(dateString, basestring):
        raise TypeError('%r is not a string' % dateString)

    return parser.parse(dateString)