registration
This commit is contained in:
35
frontend/style/node_modules/date-fns/formatRelative.js
generated
vendored
35
frontend/style/node_modules/date-fns/formatRelative.js
generated
vendored
@@ -1,12 +1,8 @@
|
||||
"use strict";
|
||||
exports.formatRelative = formatRelative;
|
||||
var _index = require("./differenceInCalendarDays.js");
|
||||
var _index2 = require("./format.js");
|
||||
|
||||
var _index3 = require("./toDate.js");
|
||||
|
||||
var _index4 = require("./_lib/defaultLocale.js");
|
||||
var _index5 = require("./_lib/defaultOptions.js");
|
||||
import { defaultLocale } from "./_lib/defaultLocale.js";
|
||||
import { getDefaultOptions } from "./_lib/defaultOptions.js";
|
||||
import { normalizeDates } from "./_lib/normalizeDates.js";
|
||||
import { differenceInCalendarDays } from "./differenceInCalendarDays.js";
|
||||
import { format } from "./format.js";
|
||||
|
||||
/**
|
||||
* The {@link formatRelative} function options.
|
||||
@@ -29,8 +25,6 @@ var _index5 = require("./_lib/defaultOptions.js");
|
||||
* | Next 6 days | Sunday at 04:30 AM |
|
||||
* | Other | 12/31/2017 |
|
||||
*
|
||||
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
||||
*
|
||||
* @param date - The date to format
|
||||
* @param baseDate - The date to compare with
|
||||
* @param options - An object with options
|
||||
@@ -48,13 +42,11 @@ var _index5 = require("./_lib/defaultOptions.js");
|
||||
* const result = formatRelative(subDays(new Date(), 6), new Date())
|
||||
* //=> "last Thursday at 12:45 AM"
|
||||
*/
|
||||
function formatRelative(date, baseDate, options) {
|
||||
const _date = (0, _index3.toDate)(date);
|
||||
const _baseDate = (0, _index3.toDate)(baseDate);
|
||||
export function formatRelative(date, baseDate, options) {
|
||||
const [date_, baseDate_] = normalizeDates(options?.in, date, baseDate);
|
||||
|
||||
const defaultOptions = (0, _index5.getDefaultOptions)();
|
||||
const locale =
|
||||
options?.locale ?? defaultOptions.locale ?? _index4.defaultLocale;
|
||||
const defaultOptions = getDefaultOptions();
|
||||
const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale;
|
||||
const weekStartsOn =
|
||||
options?.weekStartsOn ??
|
||||
options?.locale?.options?.weekStartsOn ??
|
||||
@@ -62,7 +54,7 @@ function formatRelative(date, baseDate, options) {
|
||||
defaultOptions.locale?.options?.weekStartsOn ??
|
||||
0;
|
||||
|
||||
const diff = (0, _index.differenceInCalendarDays)(_date, _baseDate);
|
||||
const diff = differenceInCalendarDays(date_, baseDate_);
|
||||
|
||||
if (isNaN(diff)) {
|
||||
throw new RangeError("Invalid time value");
|
||||
@@ -85,9 +77,12 @@ function formatRelative(date, baseDate, options) {
|
||||
token = "other";
|
||||
}
|
||||
|
||||
const formatStr = locale.formatRelative(token, _date, _baseDate, {
|
||||
const formatStr = locale.formatRelative(token, date_, baseDate_, {
|
||||
locale,
|
||||
weekStartsOn,
|
||||
});
|
||||
return (0, _index2.format)(_date, formatStr, { locale, weekStartsOn });
|
||||
return format(date_, formatStr, { locale, weekStartsOn });
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default formatRelative;
|
||||
|
||||
Reference in New Issue
Block a user