From 78d9afd187dc54c2030f7451f0e4b8e9cd52734e Mon Sep 17 00:00:00 2001 From: Richard Toth Date: Mon, 5 Oct 2020 16:14:53 +0200 Subject: [PATCH] shift expire date to next month, when deposit happens on the last day of month --- template/templates/money_deposit_create.tpl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/template/templates/money_deposit_create.tpl b/template/templates/money_deposit_create.tpl index 85fbc53..52128ed 100644 --- a/template/templates/money_deposit_create.tpl +++ b/template/templates/money_deposit_create.tpl @@ -97,9 +97,13 @@ if (pdata['l_expire_type'] == '1') { //var today = new Date(); - var today = new Date($('#mod_date').val()); + var today = new Date($('#mod_date').val() + " 00:00:00"); //var nextMonthBeginning = new Date(today.getFullYear(), today.getMonth() + 1, 1); var lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+1, 0); + //console.log(lastDayOfMonth, today, lastDayOfMonth.getTime() === today.getTime()); + if (lastDayOfMonth.getTime() === today.getTime()) { + lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+2, 0); + } $('#expire_date').html(lastDayOfMonth.getFullYear() + '-' + ('0' + (lastDayOfMonth.getMonth()+1)).slice(-2) + '-' + ('0' + lastDayOfMonth.getDate()).slice(-2)); $('#mod_expire_date').val(lastDayOfMonth.getFullYear() + '-' + ('0' + (lastDayOfMonth.getMonth()+1)).slice(-2) + '-' + ('0' + lastDayOfMonth.getDate()).slice(-2));