]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Cast year input to int
authorEli Edrian Tan <eltan2@up.edu.ph>
Thu, 17 Oct 2019 06:39:47 +0000 (14:39 +0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Fri, 24 Apr 2020 17:29:18 +0000 (20:29 +0300)
src/lib/moment/get-set.js

index f69d09c97fe6a15a9040e3ae56168054151108b0..a3274b2b92d308f82c9f6b7ac996134f2436fc3e 100644 (file)
@@ -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 {