29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
export class GlobalfunctionExtension {
|
|
|
|
public static getFirstDateofMonth(inputDate: Date): Date {
|
|
inputDate = new Date(inputDate);
|
|
return new Date(inputDate.getFullYear(), inputDate.getMonth(), 1);
|
|
}
|
|
public static getLastDateOfMonth(inputDate: Date): Date {
|
|
const lastDate = new Date(inputDate);
|
|
lastDate.setMonth(lastDate.getMonth() + 1, 0);
|
|
return lastDate;
|
|
}
|
|
public static capitalizeFirstLetter(inputString: string): string {
|
|
debugger;
|
|
if (inputString.length === 0) {
|
|
return inputString; // Return an empty string if input is empty
|
|
}
|
|
return inputString.charAt(0).toUpperCase() + inputString.slice(1);
|
|
}
|
|
public static generateVersionNumber(date: Date): string {
|
|
const year = date.getFullYear();
|
|
// const month = this.padZero(date.getMonth() + 1); // Adding 1 because months are zero-based
|
|
const month = (date.getMonth() + 1) < 10 ? `0${(date.getMonth() + 1)}` : `${(date.getMonth() + 1)}`; // Adding 1 because months are zero-based
|
|
const day = (date.getDate()) < 10 ? `0${date.getDate()}` : `${date.getDate()}`;
|
|
|
|
return `${year}${month}${day}`;
|
|
}
|
|
}
|
|
|