Created
March 30, 2018 22:56
-
-
Save duaneleem/2382ef52055f1e6e68ec5a2407f3dbc2 to your computer and use it in GitHub Desktop.
Adds a year to the current year.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {string} currentDate - The current date. | |
* @returns {string} Returns the new expiration date. | |
*/ | |
private addYear = (currentDate: string): string => { | |
// Add a day to the current date. | |
let objDate = new Date(currentDate); | |
objDate.setDate(objDate.getDate() + 1); | |
// Format the month. | |
let numMonth = objDate.getMonth() + 1; | |
let strMonth = numMonth.toString(); | |
if (numMonth < 10) { strMonth = "0" + numMonth; } | |
// Format the day. | |
let numDay = objDate.getDate(); | |
let strDay = numDay.toString(); | |
if (numDay < 10) { strDay = "0" + numDay; } | |
// Add a year to the current date. | |
let newExpiration = | |
(objDate.getFullYear() + 1).toString() + "-" + | |
strMonth + "-" + | |
strDay | |
; // strInvoiceNum | |
return newExpiration; | |
} // addYear(currentDate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment