Ejemplo n.º 1
0
/** shift_time				- shift given timespan left/right
 * @param array &$span		- given timespan (start/end time as time-since-epoch and human readable)
 * @param string $direction	- "-" for shifting left, "+" for shifting right
 * @param int $shift_size	- amount of shifting
 * @param array $_SESSION	- set to CUSTOM
 * @param array $_POST		- set to CUSTOM
 */
function shift_time(&$span, $direction, $shift_size) {
	require_once(CACTI_BASE_PATH . "/include/graph/graph_constants.php");
	# move left/right according to $direction
	# amount to be moved is derived from $shift_size
	# base dates are taken from array $span

	# is this a month shift AND current timespane is on month boundaries?
	if ( month_shift($shift_size) && check_month_boundaries($span) ) {
		# shift left boundary
		$span["begin_now"] 	= strtotime($direction . $shift_size . " " . $span["current_value_date1"]);
		# shifting right boundary is somewhat complicated
		$span["end_now"] 	= shift_right_boundary($span, $direction, $shift_size);
	} else {
		# 'normal' time shifting: use strtotime magic
		$span["begin_now"] 	= strtotime($direction . $shift_size . " " . $span["current_value_date1"]);
		$span["end_now"] 	= strtotime($direction . $shift_size . " " . $span["current_value_date2"]);
	}

	# convert to human readable format
	$span["current_value_date1"] = date("Y-m-d H:i", $span["begin_now"]);
	$span["current_value_date2"] = date("Y-m-d H:i", $span["end_now"]);

	# now custom time settings in effect
	$_SESSION["sess_current_timespan"] = GT_CUSTOM;
	$_SESSION["custom"] = 1;
	$_POST["predefined_timespan"] = GT_CUSTOM;
}
Ejemplo n.º 2
0
Archivo: time.php Proyecto: MrWnn/cacti
function shift_time(&$span, $direction, $shift_size)
{
    # move left/right according to $direction
    # amount to be moved is derived from $shift_size
    # base dates are taken from array $span
    # is this a month shift AND current timespane is on month boundaries?
    if (month_shift($shift_size) && check_month_boundaries($span)) {
        # shift left boundary
        $span['begin_now'] = strtotime($direction . $shift_size . ' ' . $span['current_value_date1']);
        # shifting right boundary is somewhat complicated
        $span['end_now'] = shift_right_boundary($span, $direction, $shift_size);
    } else {
        # 'normal' time shifting: use strtotime magic
        $span['begin_now'] = strtotime($direction . $shift_size . ' ' . $span['current_value_date1']);
        $span['end_now'] = strtotime($direction . $shift_size . ' ' . $span['current_value_date2']);
    }
    # convert to human readable format
    $span['current_value_date1'] = date('Y-m-d H:i', $span['begin_now']);
    $span['current_value_date2'] = date('Y-m-d H:i', $span['end_now']);
    # now custom time settings in effect
    $_SESSION['sess_current_timespan'] = GT_CUSTOM;
    $_SESSION['custom'] = 1;
    $_POST['predefined_timespan'] = GT_CUSTOM;
}