(see Timezone#period_for)
4363
def period_for(time)
      raise ArgumentError, 'time must be specified' unless time
      timestamp = Timestamp.for(time)
      raise ArgumentError, 'time must have a specified utc_offset' unless timestamp.utc_offset
      info.period_for(timestamp)
    end
41503
public function spans($time_period)
    {
        $time_period = self::parseTimePeriod($time_period);

        // If the date range does not have a bound then it will not span any time periods.
        if (! $this->isBounded()) {
            return false;
        }

        // After must be positioned at the end of the time period
        $end = self::forTimePeriod($time_period, $this->after)->end();
        if (! $end->eq($this->after)) {
            return;
        }

        // Before must be positioned at the start of the time period
        $start = self::forTimePeriod($time_period, $this->before)->start();
        if (! $start->eq($this->before)) {
            return;
        }

        // The start of the date range should equal the end of the date range set back to the start of its time period.
        // This ensures that the range spans only a single time period; otherwise if we only checked the bounds, they
        // could be two or more time periods apart.
        if (! self::forTimePeriod($time_period, $this->end())->start()->eq($this->start())) {
            return;
        }

        return $this->start();
    }
1249721
def get_time_period(value):
        
        for time_period in TimePeriod:
            if time_period.period == value:
                return time_period
        raise ValueError('{} is not a valid TimePeriod'.format(value))
1359391
def timedelta2period(duration):
    """"""
    seconds = duration.seconds
    minutes = (seconds % 3600) // 60
    seconds = (seconds % 60)
    return '{0:0>2}:{1:0>2}'.format(minutes, seconds)
124432
def get_period_last_week() -> str:
    
    today = Datum()
    today.start_of_day()
    # start_date = today - timedelta(days=7)
    start_date = today.clone()
    start_date.subtract_days(7)

    period = get_period(start_date.value, today.value)
    return period
79681
def grace_period=(mins)
      mins = JSS::Validate.integer(mins)
      mins = 0 if mins.negative?
      return if mins == grace_period
      @grace_period = mins
      @need_to_update = true
    end
715579
def period_break(dates, period):
    
    current = getattr(dates, period)
    previous = getattr(dates - 1 * dates.freq, period)
    return np.nonzero(current - previous)[0]
506621
public final void setTimeZone(final TimeZone timeZone) {
        for (final Period period : this) {
            period.setTimeZone(timeZone);
        }
        this.timezone = timeZone;
        this.utc = false;
    }
1089504
public String print(ReadablePeriod period) {
        checkPrinter();
        checkPeriod(period);
        
        PeriodPrinter printer = getPrinter();
        StringBuffer buf = new StringBuffer(printer.calculatePrintedLength(period, iLocale));
        printer.printTo(buf, period, iLocale);
        return buf.toString();
    }
1101795
def finished_at
      v = RRRSpec.redis.hget(key, 'finished_at')
      v.present? ? Time.zone.parse(v) : nil
    end
520464
def parse_last_period(last):
    
    
    wordmap = {
        'hour': '1h',
        'day': '1d',
        'week': '1w',
        'month': '1m'
    }

    # seconds
    multmap = {
        'h': 3600,
        'd': 86400,
        'w': 604800,
        'm': 2592000
    }

    if last in wordmap:
        last = wordmap[last]

    cat = last[-1:].lower()

    if cat not in multmap:
        raise TypeError

    try: 
        num = int(last[:-1])
        if num <= 0:
            raise TypeError
    except ValueError: 
        raise TypeError
    
    diff = num * multmap[cat]    
    return diff
287159
def usage_report(node)
      period_start = node.at('period_start')
      period_end = node.at('period_end')

      { :metric        => node['metric'].to_s.strip,
        :period        => node['period'].to_s.strip.to_sym,
        :period_start  => period_start ? period_start.content : '',
        :period_end    => period_end ? period_end.content : '',
        :current_value => node.at('current_value').content.to_i,
        :max_value     => node.at('max_value').content.to_i }
    end
365416
def to_utc_comparison_s

      per = @zone.period_for_utc(utc)
      off = per.utc_total_offset

      off = off / 3600
      off = off >= 0 ? "+#{off}" : off.to_s

      strftime('%H%M') + off + utc.strftime('(%H%M)')
    end
1229162
def timesince(when):
    
    if not when:
        return ''

    now = datetime.datetime.utcnow()
    if now > when:
        diff = now - when
        suffix = 'ago'
    else:
        diff = when - now
        suffix = 'from now'

    periods = (
        (diff.days / 365, 'year', 'years'),
        (diff.days / 30, 'month', 'months'),
        (diff.days / 7, 'week', 'weeks'),
        (diff.days, 'day', 'days'),
        (diff.seconds / 3600, 'hour', 'hours'),
        (diff.seconds / 60, 'minute', 'minutes'),
        (diff.seconds, 'second', 'seconds'),
    )

    for period, singular, plural in periods:
        if period:
            return '%d %s %s' % (
                period,
                singular if period == 1 else plural,
                suffix)

    return 'now'
877856
def period(
    start, end, absolute=False  # type: DateTime  # type: DateTime  # type: bool
):  # type: (...) -> Period
    
    return Period(start, end, absolute=absolute)
1195912
def is_period_current(self):
		

		return self.current_period_end > timezone.now() or (
			self.trial_end and self.trial_end > timezone.now()
		)
537739
public static ReadablePeriod parsePeriodString(final String periodStr) {
    final ReadablePeriod period;
    final char periodUnit = periodStr.charAt(periodStr.length() - 1);
    if (periodStr.equals("null") || periodUnit == 'n') {
      return null;
    }

    final int periodInt =
        Integer.parseInt(periodStr.substring(0, periodStr.length() - 1));
    switch (periodUnit) {
      case 'y':
        period = Years.years(periodInt);
        break;
      case 'M':
        period = Months.months(periodInt);
        break;
      case 'w':
        period = Weeks.weeks(periodInt);
        break;
      case 'd':
        period = Days.days(periodInt);
        break;
      case 'h':
        period = Hours.hours(periodInt);
        break;
      case 'm':
        period = Minutes.minutes(periodInt);
        break;
      case 's':
        period = Seconds.seconds(periodInt);
        break;
      default:
        throw new IllegalArgumentException("Invalid schedule period unit '"
            + periodUnit);
    }

    return period;
  }