registration

This commit is contained in:
User
2025-02-02 16:08:03 +03:00
parent 7f6495eb4d
commit 78afbaed71
6334 changed files with 196774 additions and 165754 deletions

View File

@@ -1,6 +1,4 @@
"use strict";
exports.transpose = transpose;
var _index = require("./constructFrom.js");
import { constructFrom } from "./constructFrom.js";
/**
* @name transpose
@@ -12,10 +10,10 @@ var _index = require("./constructFrom.js");
* to transpose the date in the system time zone to say `UTCDate` or any other
* date extension.
*
* @typeParam DateInputType - The input `Date` type derived from the passed argument.
* @typeParam DateOutputType - The output `Date` type derived from the passed constructor.
* @typeParam InputDate - The input `Date` type derived from the passed argument.
* @typeParam ResultDate - The result `Date` type derived from the passed constructor.
*
* @param fromDate - The date to use values from
* @param date - The date to use values from
* @param constructor - The date constructor to use
*
* @returns Date transposed to the given constructor
@@ -30,21 +28,26 @@ var _index = require("./constructFrom.js");
* transpose(date, UTCDate)
* //=> 'Sun Jul 10 2022 00:00:00 GMT+0000 (Coordinated Universal Time)'
*/
function transpose(fromDate, constructor) {
const date =
constructor instanceof Date
? (0, _index.constructFrom)(constructor, 0)
: new constructor(0);
date.setFullYear(
fromDate.getFullYear(),
fromDate.getMonth(),
fromDate.getDate(),
export function transpose(date, constructor) {
const date_ = isConstructor(constructor)
? new constructor(0)
: constructFrom(constructor, 0);
date_.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
date_.setHours(
date.getHours(),
date.getMinutes(),
date.getSeconds(),
date.getMilliseconds(),
);
date.setHours(
fromDate.getHours(),
fromDate.getMinutes(),
fromDate.getSeconds(),
fromDate.getMilliseconds(),
);
return date;
return date_;
}
function isConstructor(constructor) {
return (
typeof constructor === "function" &&
constructor.prototype?.constructor === constructor
);
}
// Fallback for modularized imports:
export default transpose;