Decode a DateInterval Interval spec format
@throws Exception
345086
protected function decodeIntervalSpec(): void
    {
        $this->di = new DateInterval($this->expression);
        $this->time = (new DateTime('@0'))
            ->add($this->di)
            ->getTimestamp();
    }
1270779
private Integer getFrequency(Project.Calendars.Calendar.Exceptions.Exception exception)
   {
      Integer period = NumberHelper.getInteger(exception.getPeriod());
      if (period == null)
      {
         period = Integer.valueOf(1);
      }
      return period;
   }
268214
@Override
	public String formatStatusMessage(IntervalProperty[] properties) {

		StringBuffer buff = new StringBuffer(500);	
		buff.append( "Watchdog: ");
		
		for( IntervalProperty p : properties ) {
			buff.append(p.getName());
			buff.append("=");
			buff.append(p.getValue());
			buff.append(", ");
		}
		
		if( buff.toString().endsWith(","))
			buff.setLength(buff.length()-1);

		return buff.toString();
		
	}
422785
function parseInterval(){
  var options = Array.prototype.slice.call(arguments);
  return function(res){
    var dataset = new Dataset()
      .type('interval');
    each(res.result, function(record, i){
      var index = options[0] && options[0] === 'timeframe.end' ? record.timeframe.end : record.timeframe.start;
      dataset.set(['Result', index], record.value);
    });
    return dataset;
  }
}
856913
public function toSpec(\DateInterval $interval = null)
    {
        if ((null === $interval) && isset($this)) {
            $interval = $this;
        }

        $string = 'P';

        foreach (self::$date as $property => $suffix) {
            if ($interval->{$property}) {
                $string .= $interval->{$property} . $suffix;
            }
        }

        if ($interval->h || $interval->i || $interval->s) {
            $string .= 'T';

            foreach (self::$time as $property => $suffix) {
                if ($interval->{$property}) {
                    $string .= $interval->{$property} . $suffix;
                }
            }
        }

        return $string;
    }
1205211
@Override public void intervalUpdated(Interval caller) {
		output.out("===============================================================================");
		output.out("=== SNAPSHOT Interval "+interval.getName()+" updated, Entity: "+id);
		output.out("=== Timestamp: "+Date.currentDate()+", ServiceId: "+target.getProducerId());
		output.out("===============================================================================");
		
		for (IStats stat: target.getStats()){
			output.out(stat.toStatsString(interval.getName()));
		}
		
		output.out("===============================================================================");
		output.out("== END: Interval "+interval.getName()+", Entity: "+id);
		output.out("===============================================================================");
		
	}
27747
public function formatInterval(\DateInterval $dateInterval): string
    {
        $format = 'P';

        if (0 < $dateInterval->y) {
            $format .= $dateInterval->y.'Y';
        }

        if (0 < $dateInterval->m) {
            $format .= $dateInterval->m.'M';
        }

        if (0 < $dateInterval->d) {
            $format .= $dateInterval->d.'D';
        }

        if (0 < $dateInterval->h || 0 < $dateInterval->i || 0 < $dateInterval->s) {
            $format .= 'T';
        }

        if (0 < $dateInterval->h) {
            $format .= $dateInterval->h.'H';
        }

        if (0 < $dateInterval->i) {
            $format .= $dateInterval->i.'M';
        }

        if (0 < $dateInterval->s) {
            $format .= $dateInterval->s.'S';
        }

        return $format;
    }
1256377
private function parseDateInterval($interval)
    {
        try {
            if (!$this->isInstanceOf($interval, 'DateInterval')) {
                $interval = new StringObject($interval);
                if ($interval->startsWith('P')) {
                    $interval = new \DateInterval($interval);
                } else {
                    $interval = \DateInterval::createFromDateString($interval);
                }
            }
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_INVALID_DATE_INTERVAL, [$interval]);
        }

        return $interval;
    }
450344
protected function resolveBaseFormat(\DateInterval $interval): string
    {
        $format = '';

        if ($interval->y > 0) {
            $format .= '%yY';
        }

        if ($interval->m > 0) {
            $format .= '%mM';
        }

        if ($interval->d > 0) {
            $format .= '%dD';
        }

        return $format;
    }
212769
public function getDeletedAtTimestamp(): ?int
    {
        if (!$this->isDeleted()) {
            return null;
        }

	    $timestamp = strtotime($this->getDeletedAt() . 'UTC');

	    if ($timestamp === false) {
		    throw new Exception("Unable to get timestamp from \"{$this->getDeletedAt()}\"");
	    }

	    return $timestamp;
    }
1019829
def parse_repeating_time_interval_to_str(date_str):
    

    with open(os.path.join(ABSOLUTE_SCHEMA_DIR,
                           "accrualPeriodicity.json"), "r") as f:
        freqs_map = {freq["id"]: freq["description"]
                     for freq in json.load(f)}

    return freqs_map[date_str]
854114
private DateTimeData parseCalendar(JsonObject root) throws IOException {
    DateTimeData data = new DateTimeData();
    JsonObject node = resolve(root, "dates", "calendars", "gregorian");

    data.eras = parseEras(node);
    data.dayPeriodsFormat = parseDayPeriods(node, "format");
    data.dayPeriodsStandalone = parseDayPeriods(node, "stand-alone");
    data.monthsFormat = parseMonths(node, "format");
    data.monthsStandalone = parseMonths(node, "stand-alone");
    data.weekdaysFormat = parseWeekdays(node, "format");
    data.weekdaysStandalone = parseWeekdays(node, "stand-alone");
    data.quartersFormat = parseQuarters(node, "format");
    data.quartersStandalone = parseQuarters(node, "stand-alone");
    data.dateFormats = parseDateFormats(node);
    data.timeFormats = parseTimeFormats(node);
    data.dateTimeFormats = parseDateTimeFormats(node);
    data.dateTimeSkeletons = parseDateTimeSkeletons(node);

    // date time intervals and fallback format
    data.intervalFormats = new HashMap<>();
    node = resolve(node, "dateTimeFormats", "intervalFormats");
    for (String key : objectKeys(node)) {
      if (key.equals("intervalFormatFallback")) {
        data.intervalFallbackFormat = string(node, key);
      } else {
        Map<String, String> format = data.intervalFormats.get(key);
        if (format == null) {
          format = new HashMap<>();
          data.intervalFormats.put(key, format);
        }
        
        JsonObject fieldNode = node.getAsJsonObject(key);
        for (String field : objectKeys(fieldNode)) {
          if (!field.endsWith("-alt-variant")) {
            format.put(field, string(fieldNode, field));
          }
        }
      }
    }
    
    return data;
  }
209814
public static function intervalToTime(DateInterval $interval)
    {
        $time = null;

        if (!is_null($interval)) {
            $format = property_exists(get_class($interval), 'u') ? '%H:%I:%S.%U' : '%H:%I:%S';
            $time = $interval->format($format);
        }

        return $time;
    }
989474
public Interval toInterval() {
        DateTimeField field = getField();
        long start = field.roundFloor(getMillis());
        long end = field.add(start, 1);
        Interval interval = new Interval(start, end, getChronology());
        return interval;
    }
62485
private function getIntervalUnits(\DateTime $date1, \DateTime $date2, string $intervalFormat)
    {
        $result = 0;
        try {
            $interval = new \DateInterval($intervalFormat);
            $periods  = new \DatePeriod($date1, $interval, $date2);

            $result = max(0, iterator_count($periods) - 1);
        } catch (\Exception $e) {
        }

        return $result;
    }
1000785
public static function getDateIntervalSpec(DateInterval $interval)
    {
        $date = array_filter([
            static::PERIOD_YEARS => abs($interval->y),
            static::PERIOD_MONTHS => abs($interval->m),
            static::PERIOD_DAYS => abs($interval->d),
        ]);

        $time = array_filter([
            static::PERIOD_HOURS => abs($interval->h),
            static::PERIOD_MINUTES => abs($interval->i),
            static::PERIOD_SECONDS => abs($interval->s),
        ]);

        $specString = static::PERIOD_PREFIX;

        foreach ($date as $key => $value) {
            $specString .= $value.$key;
        }

        if (count($time) > 0) {
            $specString .= static::PERIOD_TIME_PREFIX;
            foreach ($time as $key => $value) {
                $specString .= $value.$key;
            }
        }

        return $specString === static::PERIOD_PREFIX ? 'PT0S' : $specString;
    }
358915
public void setInto(ReadWritableInterval writableInterval, Object object, Chronology chrono) {
        String str = (String) object;

        int separator = str.indexOf('/');
        if (separator < 0) {
            throw new IllegalArgumentException("Format requires a '/' separator: " + str);
        }

        String leftStr = str.substring(0, separator);
        if (leftStr.length() <= 0) {
            throw new IllegalArgumentException("Format invalid: " + str);
        }
        String rightStr = str.substring(separator + 1);
        if (rightStr.length() <= 0) {
            throw new IllegalArgumentException("Format invalid: " + str);
        }

        DateTimeFormatter dateTimeParser = ISODateTimeFormat.dateTimeParser();
        dateTimeParser = dateTimeParser.withChronology(chrono);
        PeriodFormatter periodParser = ISOPeriodFormat.standard();
        long startInstant = 0, endInstant = 0;
        Period period = null;
        Chronology parsedChrono = null;
        
        // before slash
        char c = leftStr.charAt(0);
        if (c == 'P' || c == 'p') {
            period = periodParser.withParseType(getPeriodType(leftStr)).parsePeriod(leftStr);
        } else {
            DateTime start = dateTimeParser.parseDateTime(leftStr);
            startInstant = start.getMillis();
            parsedChrono = start.getChronology();
        }
        
        // after slash
        c = rightStr.charAt(0);
        if (c == 'P' || c == 'p') {
            if (period != null) {
                throw new IllegalArgumentException("Interval composed of two durations: " + str);
            }
            period = periodParser.withParseType(getPeriodType(rightStr)).parsePeriod(rightStr);
            chrono = (chrono != null ? chrono : parsedChrono);
            endInstant = chrono.add(period, startInstant, 1);
        } else {
            DateTime end = dateTimeParser.parseDateTime(rightStr);
            endInstant = end.getMillis();
            parsedChrono = (parsedChrono != null ? parsedChrono : end.getChronology());
            chrono = (chrono != null ? chrono : parsedChrono);
            if (period != null) {
                startInstant = chrono.add(period, endInstant, -1);
            }
        }
        
        writableInterval.setInterval(startInstant, endInstant);
        writableInterval.setChronology(chrono);
    }