Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/react-intl/lib/formatters/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /*
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
import { filterProps, getNamedFormat } from '../utils';
import { ReactIntlError } from '../error';
const DATE_TIME_FORMAT_OPTIONS = [
'localeMatcher',
'formatMatcher',
'timeZone',
'hour12',
'weekday',
'era',
'year',
'month',
'day',
'hour',
'minute',
'second',
'timeZoneName',
];
export function getFormatter({ locale, formats, onError, timeZone, }, type, getDateTimeFormat, options = {}) {
const { format } = options;
const defaults = Object.assign(Object.assign({}, (timeZone && { timeZone })), (format && getNamedFormat(formats, type, format, onError)));
let filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults);
if (type === 'time' &&
!filteredOptions.hour &&
!filteredOptions.minute &&
!filteredOptions.second) {
// Add default formatting options if hour, minute, or second isn't defined.
filteredOptions = Object.assign(Object.assign({}, filteredOptions), { hour: 'numeric', minute: 'numeric' });
}
return getDateTimeFormat(locale, filteredOptions);
}
export function formatDate(config, getDateTimeFormat, value, options = {}) {
const date = typeof value === 'string' ? new Date(value || 0) : value;
try {
return getFormatter(config, 'date', getDateTimeFormat, options).format(date);
}
catch (e) {
config.onError(new ReactIntlError("FORMAT_ERROR" /* FORMAT_ERROR */, 'Error formatting date.', e));
}
return String(date);
}
export function formatTime(config, getDateTimeFormat, value, options = {}) {
const date = typeof value === 'string' ? new Date(value || 0) : value;
try {
return getFormatter(config, 'time', getDateTimeFormat, options).format(date);
}
catch (e) {
config.onError(new ReactIntlError("FORMAT_ERROR" /* FORMAT_ERROR */, 'Error formatting time.', e));
}
return String(date);
}
export function formatDateToParts(config, getDateTimeFormat, value, options = {}) {
const date = typeof value === 'string' ? new Date(value || 0) : value;
try {
return getFormatter(config, 'date', getDateTimeFormat, options).formatToParts(date);
}
catch (e) {
config.onError(new ReactIntlError("FORMAT_ERROR" /* FORMAT_ERROR */, 'Error formatting date.', e));
}
return [];
}
export function formatTimeToParts(config, getDateTimeFormat, value, options = {}) {
const date = typeof value === 'string' ? new Date(value || 0) : value;
try {
return getFormatter(config, 'time', getDateTimeFormat, options).formatToParts(date);
}
catch (e) {
config.onError(new ReactIntlError("FORMAT_ERROR" /* FORMAT_ERROR */, 'Error formatting time.', e));
}
return [];
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0449 ]-- |