/** * Decomposes an 'exact_date' parameter into month, day, year components based * on date pattern defined in settings (assumed to be in local time zone), * then returns a timestamp in GMT. * * @param string $exact_date 'exact_date' parameter passed to a view * @return bool|int false if argument not provided or invalid, * else UNIX timestamp in GMT */ private function return_gmtime_from_exact_date($exact_date) { global $ai1ec_settings; $bits = Ai1ec_Validation_Utility::validate_date_and_return_parsed_date($exact_date, $ai1ec_settings->input_date_format); if (false === $bits) { $exact_date = false; } else { $exact_date = Ai1ec_Time_Utility::local_to_gmt(gmmktime(0, 0, 0, $bits['month'], $bits['day'], $bits['year'])); } return $exact_date; }
/** * Returns a non-associative array of four links for the day view of the * calendar: * previous day, and next day. * Each element is an associative array containing the link's enabled status * ['enabled'], CSS class ['class'], text ['text'] and value to assign to * link's href ['href']. * * @param array $args Current request arguments * * @return array Array of links */ function get_oneday_pagination_links($args) { $links = array(); $orig_date = $args['exact_date']; $local_date = Ai1ec_Time_Utility::gmt_to_local($args['exact_date']); $bits = Ai1ec_Time_Utility::gmgetdate($local_date); // ================ // = Previous day = // ================ $local_date = gmmktime(0, 0, 0, $bits['mon'], $bits['mday'] + $args['oneday_offset'] - 1, $bits['year']); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $href = Ai1ec_View_Factory::create_href_helper_instance($args); $links[] = array('enabled' => true, 'class' => 'ai1ec-prev-day', 'text' => '<i class="icon-chevron-left"></i>', 'href' => $href->generate_href()); // ====================== // = Minical datepicker = // ====================== $args['exact_date'] = $orig_date; $links[] = Ai1ec_View_Factory::create_datepicker_link($args, $args['exact_date']); // ============= // = Next week = // ============= $local_date = gmmktime(0, 0, 0, $bits['mon'], $bits['mday'] + $args['oneday_offset'] + 1, $bits['year']); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $href = Ai1ec_View_Factory::create_href_helper_instance($args); $links[] = array('enabled' => true, 'class' => 'ai1ec-next-day', 'text' => '<i class="icon-chevron-right"></i>', 'href' => $href->generate_href()); return $links; }
/** * local_to_gmt function * * Returns the UNIX timestamp adjusted from the local timezone to GMT. * * @param int $timestamp * * @return int **/ function local_to_gmt($timestamp) { return Ai1ec_Time_Utility::local_to_gmt($timestamp); }