From c55235d7d4bed1068ab3d6f2bad7338ccd4445b6 Mon Sep 17 00:00:00 2001 From: Sarah Chintomby Date: Tue, 18 Jun 2019 10:21:10 -0400 Subject: [PATCH] [DEV-5546] Move edge case code for month --- src/calc/Calc.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/calc/Calc.js b/src/calc/Calc.js index a067a51..da611ec 100644 --- a/src/calc/Calc.js +++ b/src/calc/Calc.js @@ -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() + '-'