1
0
Fork 0

[DEV-5546] Move edge case code for month

master
Sarah Chintomby 2019-06-18 10:21:10 -04:00
parent 716f2b1a32
commit c55235d7d4
1 changed files with 7 additions and 8 deletions

View File

@ -270,6 +270,13 @@ exports.relativeDate = function( data, value )
// months
case 'm':
date_new.setMonth( date_new.getMonth() + +tval );
// when adding a month to the last day of the month
// make sure the new date is also the last day of the month
// and not the first day of the next
if( date_new.getUTCDate() !== now_day )
{
date_new.setUTCDate(0);
}
break;
// days
@ -286,14 +293,6 @@ exports.relativeDate = function( data, value )
return '';
}
// when adding a month to the last day of the month
// make sure the new date is also the last day of the month
// and not the first day of the next
if( type === 'm' && date_new.getUTCDate() !== now_day )
{
date_new.setUTCDate(0);
}
// return in the YYYY-MM-DD format, since that's what our fields are
// formatted as
return date_new.getFullYear() + '-'