PATH:
home
/
centosnipponia
/
public_html
/
nipponiacar
/
wp-content
/
plugins
/
google-site-kit
/
includes
/
Core
/
Util
<?php /** * Class Google\Site_Kit\Core\Util\Date * * @package Google\Site_Kit\Core\Util * @copyright 2023 Google LLC * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * @link https://sitekit.withgoogle.com */ namespace Google\Site_Kit\Core\Util; /** * Class for custom date parsing methods. * * @since 1.99.0 * @access private * @ignore */ class Date { /** * Gets the reference date. * * @since 1.174.0 * * @return string|null Reference date in 'Y-m-d' format or null. */ public static function reference_date() { /** * Filter to allow setting a custom reference date for testing purposes. * * @since 1.174.0 * * @return string|null Reference date in 'Y-m-d' format or null. */ return apply_filters( 'googlesitekit_reference_date', null ); } /** * Gets the current time. * * @since 1.177.0 * * @return int Current time. */ public static function now() { $reference_date = self::reference_date(); if ( $reference_date ) { $time = strtotime( $reference_date ); if ( $time ) { return $time; } } return time(); } /** * Parses a date range string into a start date and an end date. * * @since 1.99.0 * * @param string $range Date range string. Either 'last-7-days', 'last-14-days', 'last-90-days', or * 'last-28-days' (default). * @param int $multiplier Optional. How many times the date range to get. This value can be specified if the * range should be request multiple times back. Default 1. * @param int $offset Days the range should be offset by. Default 1. Used by Search Console where * data is delayed by two days. * @param bool $previous Whether to select the previous period. Default false. * @return array List with two elements, the first with the start date and the second with the end date, both as 'Y-m-d'. */ public static function parse_date_range( $range, $multiplier = 1, $offset = 1, $previous = false ) { preg_match( '*-(\d+)-*', $range, $matches ); $number_of_days = $multiplier * ( isset( $matches[1] ) ? $matches[1] : 28 ); // Calculate the end date. For previous period requests, offset period by the number of days in the request. $end_date_offset = $previous ? $offset + $number_of_days : $offset; $date_end = gmdate( 'Y-m-d', strtotime( $end_date_offset . ' days ago' ) ); // Set the start date. $start_date_offset = $end_date_offset + $number_of_days - 1; $date_start = gmdate( 'Y-m-d', strtotime( $start_date_offset . ' days ago' ) ); return array( $date_start, $date_end ); } }
[+]
..
[-] Activation_Flag.php
[edit]
[-] Activation_Notice.php
[edit]
[-] Auto_Updates.php
[edit]
[-] BC_Functions.php
[edit]
[-] Block_Support.php
[edit]
[-] Collection_Key_Cap_Filter.php
[edit]
[-] Date.php
[edit]
[-] Developer_Plugin_Installer.php
[edit]
[-] Entity_Factory.php
[edit]
[-] Entity.php
[edit]
[-] Exit_Handler.php
[edit]
[-] Feature_Flags.php
[edit]
[-] Google_Icon.php
[edit]
[-] Google_URL_Matcher_Trait.php
[edit]
[-] Google_URL_Normalizer.php
[edit]
[-] Health_Checks.php
[edit]
[-] Input.php
[edit]
[-] Method_Proxy_Trait.php
[edit]
[-] Migrate_Legacy_Keys.php
[edit]
[-] Migration_1_123_0.php
[edit]
[-] Migration_1_129_0.php
[edit]
[-] Migration_1_150_0.php
[edit]
[-] Migration_1_163_0.php
[edit]
[-] Migration_1_177_0.php
[edit]
[-] Migration_1_3_0.php
[edit]
[-] Migration_1_8_1.php
[edit]
[-] Plugin_Status.php
[edit]
[-] Requires_Javascript_Trait.php
[edit]
[-] Reset_Persistent.php
[edit]
[-] Reset.php
[edit]
[-] REST_Entity_Search_Controller.php
[edit]
[-] Sanitize.php
[edit]
[-] Scopes.php
[edit]
[-] Sort.php
[edit]
[-] Synthetic_WP_Query.php
[edit]
[-] Uninstallation.php
[edit]
[-] URL.php
[edit]
[-] WP_Context_Switcher_Trait.php
[edit]
[-] WP_Query_Factory.php
[edit]
[-] .htaccess.disabled
[edit]