Server IP : 85.214.239.14 / Your IP : 3.148.109.119 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/cwd/lib/node_modules/pm2/node_modules/@pm2/agent/node_modules/dayjs/esm/plugin/utc/ |
Upload File : |
import { MILLISECONDS_A_MINUTE, MIN } from '../../constant'; export default (function (option, Dayjs, dayjs) { var localOffset = new Date().getTimezoneOffset(); var proto = Dayjs.prototype; dayjs.utc = function (date) { var cfg = { date: date, utc: true, args: arguments }; // eslint-disable-line prefer-rest-params return new Dayjs(cfg); // eslint-disable-line no-use-before-define }; proto.utc = function () { return dayjs(this.toDate(), { locale: this.$L, utc: true }); }; proto.local = function () { return dayjs(this.toDate(), { locale: this.$L, utc: false }); }; var oldParse = proto.parse; proto.parse = function (cfg) { if (cfg.utc) { this.$u = true; } if (!this.$utils().u(cfg.$offset)) { this.$offset = cfg.$offset; } oldParse.call(this, cfg); }; var oldInit = proto.init; proto.init = function () { if (this.$u) { var $d = this.$d; this.$y = $d.getUTCFullYear(); this.$M = $d.getUTCMonth(); this.$D = $d.getUTCDate(); this.$W = $d.getUTCDay(); this.$H = $d.getUTCHours(); this.$m = $d.getUTCMinutes(); this.$s = $d.getUTCSeconds(); this.$ms = $d.getUTCMilliseconds(); } else { oldInit.call(this); } }; var oldUtcOffset = proto.utcOffset; proto.utcOffset = function (input, keepLocalTime) { var _this$$utils = this.$utils(), u = _this$$utils.u; if (u(input)) { if (this.$u) { return 0; } if (!u(this.$offset)) { return this.$offset; } return oldUtcOffset.call(this); } var offset = Math.abs(input) <= 16 ? input * 60 : input; var ins = this; if (keepLocalTime) { ins.$offset = offset; ins.$u = input === 0; return ins; } if (input !== 0) { ins = this.local().add(offset + localOffset, MIN); ins.$offset = offset; } else { ins = this.utc(); } return ins; }; var oldFormat = proto.format; var UTC_FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ss[Z]'; proto.format = function (formatStr) { var str = formatStr || (this.$u ? UTC_FORMAT_DEFAULT : ''); return oldFormat.call(this, str); }; proto.valueOf = function () { var addedOffset = !this.$utils().u(this.$offset) ? this.$offset + localOffset : 0; return this.$d.valueOf() - addedOffset * MILLISECONDS_A_MINUTE; }; proto.isUTC = function () { return !!this.$u; }; proto.toISOString = function () { return this.toDate().toISOString(); }; proto.toString = function () { return this.toDate().toUTCString(); }; var oldToDate = proto.toDate; proto.toDate = function (type) { if (type === 's' && this.$offset) { return dayjs(this.format('YYYY-MM-DD HH:mm:ss:SSS')).toDate(); } return oldToDate.call(this); }; var oldDiff = proto.diff; proto.diff = function (input, units, _float) { var localThis = this.local(); var localInput = dayjs(input).local(); return oldDiff.call(localThis, localInput, units, _float); }; });