From 5db83a9c5255ec9dd50b5783348d3f5b6a9facdf Mon Sep 17 00:00:00 2001 From: bahtya Date: Sun, 5 Apr 2026 02:24:03 +0800 Subject: [PATCH] fix: handle Dayjs object input in dayjs.utc() When passing a Dayjs object to dayjs.utc(), the result was incorrect because the raw Dayjs object went through parseDate() which called new Date(date) producing wrong results. Add isDayjs check to convert to native Date first. Fixes #1241 --- src/plugin/utc/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugin/utc/index.js b/src/plugin/utc/index.js index d565f3281..719e7dd5c 100644 --- a/src/plugin/utc/index.js +++ b/src/plugin/utc/index.js @@ -24,6 +24,7 @@ function offsetFromString(value = '') { export default (option, Dayjs, dayjs) => { const proto = Dayjs.prototype dayjs.utc = function (date) { + if (dayjs.isDayjs(date)) date = date.toDate() const cfg = { date, utc: true, args: arguments } // eslint-disable-line prefer-rest-params return new Dayjs(cfg) // eslint-disable-line no-use-before-define }