wordpress/wp-content/plugins/sqlite-integration/functions.php
/**
	 * Method to calculate the interval time between two dates value.
	 *
	 * @access private
	 * @param string $interval white space separated expression.
	 * @return string representing the time to add or substract.
	 */
Method to calculate the interval time between two dates value.
@access private
@param string $interval white space separated expression.
@return string representing the time to add or substract.
Method to calculate the interval time between two dates value . @access private @param string $interval white space separated expression . @return string representing the time to add or substract .
private function deriveInterval($interval) {
		$interval = trim(substr(trim($interval), 8));
		$parts = explode(' ', $interval);
		foreach ($parts as $part) {
			if (!empty($part)) {
				$_parts[] = $part;
			}
		}
		$type = strtolower(end($_parts));
		switch ($type) {
			case "second": $unit = 'S'; return 'PT' . $_parts[0] . $unit; break;
			case "minute": $unit = 'M'; return 'PT' . $_parts[0] . $unit; break;
			case "hour":   $unit = 'H'; return 'PT' . $_parts[0] . $unit; break;
			case "day":    $unit = 'D'; return 'P'  . $_parts[0] . $unit; break;
			case "week":   $unit = 'W'; return 'P'  . $_parts[0] . $unit; break;
			case "month":  $unit = 'M'; return 'P'  . $_parts[0] . $unit; break;
			case "year":   $unit = 'Y'; return 'P'  . $_parts[0] . $unit; break;
			case "minute_second":
				list($minutes, $seconds) = explode(':', $_parts[0]);
				return 'PT' . $minutes . 'M' . $seconds . 'S';
			case "hour_second":
				list($hours, $minutes, $seconds) = explode (':', $_parts[0]);
				return 'PT' . $hours . 'H' . $minutes . 'M' . $seconds . 'S';
			case "hour_minute":
				list($hours, $minutes) = explode (':', $_parts[0]);
				return 'PT' . $hours . 'H' . $minutes . 'M';
			case "day_second":
				$days = intval($_parts[0]);
				list($hours, $minutes, $seconds) = explode (':', $_parts[1]);
				return 'P' . $days . 'D' . 'T' . $hours . 'H' . $minutes . 'M' . $seconds . 'S';
			case "day_minute":
				$days = intval($_parts[0]);
				list($hours, $minutes) = explode(':', $parts[1]);
				return 'P' . $days . 'D' . 'T' . $hours . 'H' . $minutes . 'M';
			case "day_hour":
				$days  = intval($_parts[0]);
				$hours = intval($_parts[1]);
				return 'P' . $days . 'D' . 'T' . $hours . 'H';
			case "year_month":
				list($years, $months) = explode ('-', $_parts[0]);
				return 'P' . $years . 'Y' . $months . 'M';
		}
	}
private function deriveInterval ( $ interval ) { $ interval = trim ( substr ( trim ( $ interval ) , 8 ) ) ; $ parts = explode ( ' ' , $ interval ) ; foreach ( $ parts as $ part ) { if ( ! empty ( $ part ) ) { $ _parts [ ] = $ part ; } } $ type = strtolower ( end ( $ _parts ) ) ; switch ( $ type ) { case " second " : $ unit = 'S' ; return 'PT' . $ _parts [ 0 ] . $ unit ; break ; case " minute " : $ unit = 'M' ; return 'PT' . $ _parts [ 0 ] . $ unit ; break ; case " hour " : $ unit = 'H' ; return 'PT' . $ _parts [ 0 ] . $ unit ; break ; case " day " : $ unit = 'D' ; return 'P' . $ _parts [ 0 ] . $ unit ; break ; case " week " : $ unit = 'W' ; return 'P' . $ _parts [ 0 ] . $ unit ; break ; case " month " : $ unit = 'M' ; return 'P' . $ _parts [ 0 ] . $ unit ; break ; case " year " : $ unit = 'Y' ; return 'P' . $ _parts [ 0 ] . $ unit ; break ; case " minute_second " : list ( $ minutes , $ seconds ) = explode ( ':' , $ _parts [ 0 ] ) ; return 'PT' . $ minutes . 'M' . $ seconds . 'S' ; case " hour_second " : list ( $ hours , $ minutes , $ seconds ) = explode ( ':' , $ _parts [ 0 ] ) ; return 'PT' . $ hours . 'H' . $ minutes . 'M' . $ seconds . 'S' ; case " hour_minute " : list ( $ hours , $ minutes ) = explode ( ':' , $ _parts [ 0 ] ) ; return 'PT' . $ hours . 'H' . $ minutes . 'M' ; case " day_second " : $ days = intval ( $ _parts [ 0 ] ) ; list ( $ hours , $ minutes , $ seconds ) = explode ( ':' , $ _parts [ 1 ] ) ; return 'P' . $ days . 'D' . 'T' . $ hours . 'H' . $ minutes . 'M' . $ seconds . 'S' ; case " day_minute " : $ days = intval ( $ _parts [ 0 ] ) ; list ( $ hours , $ minutes ) = explode ( ':' , $ parts [ 1 ] ) ; return 'P' . $ days . 'D' . 'T' . $ hours . 'H' . $ minutes . 'M' ; case " day_hour " : $ days = intval ( $ _parts [ 0 ] ) ; $ hours = intval ( $ _parts [ 1 ] ) ; return 'P' . $ days . 'D' . 'T' . $ hours . 'H' ; case " year_month " : list ( $ years , $ months ) = explode ( '-' , $ _parts [ 0 ] ) ; return 'P' . $ years . 'Y' . $ months . 'M' ; } }
Method to calculate the interval time between two dates value.
Method to calculate the interval time between two dates value .