registration
This commit is contained in:
41
frontend/style/node_modules/date-fns/sub.js
generated
vendored
41
frontend/style/node_modules/date-fns/sub.js
generated
vendored
@@ -1,9 +1,10 @@
|
||||
"use strict";
|
||||
exports.sub = sub;
|
||||
var _index = require("./subDays.js");
|
||||
var _index2 = require("./subMonths.js");
|
||||
import { constructFrom } from "./constructFrom.js";
|
||||
import { subDays } from "./subDays.js";
|
||||
import { subMonths } from "./subMonths.js";
|
||||
|
||||
var _index3 = require("./constructFrom.js");
|
||||
/**
|
||||
* The {@link sub} function options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name sub
|
||||
@@ -14,9 +15,11 @@ var _index3 = require("./constructFrom.js");
|
||||
* Subtract the specified years, months, weeks, days, hours, minutes and seconds from the given date.
|
||||
*
|
||||
* @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).
|
||||
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
||||
*
|
||||
* @param date - The date to be changed
|
||||
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be subtracted
|
||||
* @param options - An object with options
|
||||
*
|
||||
* | Key | Description |
|
||||
* |---------|------------------------------------|
|
||||
@@ -45,7 +48,7 @@ var _index3 = require("./constructFrom.js");
|
||||
* })
|
||||
* //=> Mon Sep 1 2014 10:19:50
|
||||
*/
|
||||
function sub(date, duration) {
|
||||
export function sub(date, duration, options) {
|
||||
const {
|
||||
years = 0,
|
||||
months = 0,
|
||||
@@ -56,23 +59,15 @@ function sub(date, duration) {
|
||||
seconds = 0,
|
||||
} = duration;
|
||||
|
||||
// Subtract years and months
|
||||
const dateWithoutMonths = (0, _index2.subMonths)(date, months + years * 12);
|
||||
const withoutMonths = subMonths(date, months + years * 12, options);
|
||||
const withoutDays = subDays(withoutMonths, days + weeks * 7, options);
|
||||
|
||||
// Subtract weeks and days
|
||||
const dateWithoutDays = (0, _index.subDays)(
|
||||
dateWithoutMonths,
|
||||
days + weeks * 7,
|
||||
);
|
||||
const minutesToSub = minutes + hours * 60;
|
||||
const secondsToSub = seconds + minutesToSub * 60;
|
||||
const msToSub = secondsToSub * 1000;
|
||||
|
||||
// Subtract hours, minutes and seconds
|
||||
const minutestoSub = minutes + hours * 60;
|
||||
const secondstoSub = seconds + minutestoSub * 60;
|
||||
const mstoSub = secondstoSub * 1000;
|
||||
const finalDate = (0, _index3.constructFrom)(
|
||||
date,
|
||||
dateWithoutDays.getTime() - mstoSub,
|
||||
);
|
||||
|
||||
return finalDate;
|
||||
return constructFrom(options?.in || date, +withoutDays - msToSub);
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default sub;
|
||||
|
||||
Reference in New Issue
Block a user