mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
This reverts commit 1e50f1b2e5
.
This commit is contained in:
parent
2342be2bbe
commit
3b55d72e0f
@ -224,7 +224,7 @@ export class Utils {
|
|||||||
//this function makes sure that if date is the 31st and you add a month, you will get the last day of the next month
|
//this function makes sure that if date is the 31st and you add a month, you will get the last day of the next month
|
||||||
//so adding or subtracting a month from 31st of march will give 30th of april or 28th of february respectively (29th on leap years).
|
//so adding or subtracting a month from 31st of march will give 30th of april or 28th of february respectively (29th on leap years).
|
||||||
static addMonthToDate(date: Date, numMonths: number) {
|
static addMonthToDate(date: Date, numMonths: number) {
|
||||||
const result = new Date(date)
|
let result = new Date(date)
|
||||||
const expectedMonth = ((date.getMonth() + numMonths) % 12 + 12) % 12; //inner %12 + 12 makes correct handling of negative months
|
const expectedMonth = ((date.getMonth() + numMonths) % 12 + 12) % 12; //inner %12 + 12 makes correct handling of negative months
|
||||||
result.setMonth(result.getMonth() + numMonths);
|
result.setMonth(result.getMonth() + numMonths);
|
||||||
if (result.getMonth() !== expectedMonth) {
|
if (result.getMonth() !== expectedMonth) {
|
||||||
|
Loading…
Reference in New Issue
Block a user