From: Eli Edrian Tan Date: Thu, 17 Oct 2019 06:39:47 +0000 (+0800) Subject: Cast year input to int X-Git-Tag: 2.25.0~65^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=982ae03e0af22cdd388f9a93ada4640d831fe356;p=thirdparty%2Fmoment.git Cast year input to int --- diff --git a/src/lib/moment/get-set.js b/src/lib/moment/get-set.js index f69d09c97..a3274b2b9 100644 --- a/src/lib/moment/get-set.js +++ b/src/lib/moment/get-set.js @@ -4,6 +4,7 @@ import { hooks } from '../utils/hooks'; import isFunction from '../utils/is-function'; import { daysInMonth } from '../units/month'; import { isLeapYear } from '../utils/is-leap-year'; +import toInt from '../utils/to-int'; export function makeGetSet (unit, keepTime) { return function (value) { @@ -25,6 +26,7 @@ export function get (mom, unit) { export function set (mom, unit, value) { if (mom.isValid() && !isNaN(value)) { if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) { + value = toInt(value); mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month())); } else {