project files added

This commit is contained in:
mhalfmann
2021-06-15 16:00:08 +02:00
parent e156e2f053
commit db46afa351
13928 changed files with 1569902 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.
import { formatRelative } from 'date-fns'
export default formatRelative
+109
View File
@@ -0,0 +1,109 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = formatRelative;
var _index = _interopRequireDefault(require("../differenceInCalendarDays/index.js"));
var _index2 = _interopRequireDefault(require("../format/index.js"));
var _index3 = _interopRequireDefault(require("../locale/en-US/index.js"));
var _index4 = _interopRequireDefault(require("../subMilliseconds/index.js"));
var _index5 = _interopRequireDefault(require("../toDate/index.js"));
var _index6 = _interopRequireDefault(require("../_lib/getTimezoneOffsetInMilliseconds/index.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @name formatRelative
* @category Common Helpers
* @summary Represent the date in words relative to the given base date.
*
* @description
* Represent the date in words relative to the given base date.
*
* | Distance to the base date | Result |
* |---------------------------|---------------------------|
* | Previous 6 days | last Sunday at 04:30 AM |
* | Last day | yesterday at 04:30 AM |
* | Same day | today at 04:30 AM |
* | Next day | tomorrow at 04:30 AM |
* | Next 6 days | Sunday at 04:30 AM |
* | Other | 12/31/2017 |
*
* ### v2.0.0 breaking changes:
*
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
*
* @param {Date|Number} date - the date to format
* @param {Date|Number} baseDate - the date to compare with
* @param {Object} [options] - an object with options.
* @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
* @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
* @returns {String} the date in words
* @throws {TypeError} 2 arguments required
* @throws {RangeError} `date` must not be Invalid Date
* @throws {RangeError} `baseDate` must not be Invalid Date
* @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
* @throws {RangeError} `options.locale` must contain `localize` property
* @throws {RangeError} `options.locale` must contain `formatLong` property
* @throws {RangeError} `options.locale` must contain `formatRelative` property
*/
function formatRelative(dirtyDate, dirtyBaseDate, dirtyOptions) {
if (arguments.length < 2) {
throw new TypeError('2 arguments required, but only ' + arguments.length + ' present');
}
var date = (0, _index5.default)(dirtyDate);
var baseDate = (0, _index5.default)(dirtyBaseDate);
var options = dirtyOptions || {};
var locale = options.locale || _index3.default;
if (!locale.localize) {
throw new RangeError('locale must contain localize property');
}
if (!locale.formatLong) {
throw new RangeError('locale must contain formatLong property');
}
if (!locale.formatRelative) {
throw new RangeError('locale must contain formatRelative property');
}
var diff = (0, _index.default)(date, baseDate);
if (isNaN(diff)) {
throw new RangeError('Invalid time value');
}
var token;
if (diff < -6) {
token = 'other';
} else if (diff < -1) {
token = 'lastWeek';
} else if (diff < 0) {
token = 'yesterday';
} else if (diff < 1) {
token = 'today';
} else if (diff < 2) {
token = 'tomorrow';
} else if (diff < 7) {
token = 'nextWeek';
} else {
token = 'other';
}
var utcDate = (0, _index4.default)(date, (0, _index6.default)(date));
var utcBaseDate = (0, _index4.default)(baseDate, (0, _index6.default)(baseDate));
var formatStr = locale.formatRelative(token, utcDate, utcBaseDate, options);
return (0, _index2.default)(date, formatStr, options);
}
module.exports = exports.default;
+45
View File
@@ -0,0 +1,45 @@
// @flow
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.
export type Interval = {
start: Date | number,
end: Date | number
}
export type Locale = {
formatDistance: (...args: Array<any>) => any,
formatRelative: (...args: Array<any>) => any,
localize: {
ordinalNumber: (...args: Array<any>) => any,
era: (...args: Array<any>) => any,
quarter: (...args: Array<any>) => any,
month: (...args: Array<any>) => any,
day: (...args: Array<any>) => any,
dayPeriod: (...args: Array<any>) => any
},
formatLong: Object,
date: (...args: Array<any>) => any,
time: (...args: Array<any>) => any,
dateTime: (...args: Array<any>) => any,
match: {
ordinalNumber: (...args: Array<any>) => any,
era: (...args: Array<any>) => any,
quarter: (...args: Array<any>) => any,
month: (...args: Array<any>) => any,
day: (...args: Array<any>) => any,
dayPeriod: (...args: Array<any>) => any
},
options?: {
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6,
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7
}
}
declare module.exports: (
date: Date | number,
baseDate: Date | number,
options?: {
locale?: Locale,
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6
}
) => string
+5
View File
@@ -0,0 +1,5 @@
{
"sideEffects": false,
"module": "../esm/formatRelative/index.js",
"typings": "../typings.d.ts"
}