Skip to content

Commit

Permalink
Merge branch 'master' into POC-626
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqedme authored Feb 14, 2024
2 parents dcaa8a4 + 401de18 commit 873f80c
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class TxRttReportComponent
this.errorMessage = 'Locations are required!';
}
}
public getDates(currentEndDate) {
public getDates(currentEndDate: string) {
// Convert the currentEndDate string to a Date object
const currentDate = new Date(currentEndDate);

Expand All @@ -67,24 +67,19 @@ export class TxRttReportComponent
const currentYear = currentDate.getFullYear();

// Calculate the previous month's last date
const previousMonth = currentMonth === 0 ? 11 : currentMonth - 1; // Adjust for January
const previousYear = currentMonth === 0 ? currentYear - 1 : currentYear; // Subtract one year if current month is January
const previousMonthLastDate = new Date(
currentYear,
currentMonth,
0
).getDate();

// Calculate the current month's end date
const currentMonthEndDate = new Date(
currentYear,
currentMonth + 1,
previousYear,
previousMonth + 1,
0
).getDate();

// Format the dates as strings in the "YYYY-MM-DD" format
const previousMonthLastDateString =
currentYear +
previousYear +
'-' +
currentMonth.toString().padStart(2, '0') +
(previousMonth + 1).toString().padStart(2, '0') +
'-' +
previousMonthLastDate.toString().padStart(2, '0');
const currentMonthEndDateString = currentEndDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class TxMlReportComponent
};
}

public getDates(currentEndDate) {
public getDates(currentEndDate: string) {
// Convert the currentEndDate string to a Date object
const currentDate = new Date(currentEndDate);

Expand All @@ -130,24 +130,19 @@ export class TxMlReportComponent
const currentYear = currentDate.getFullYear();

// Calculate the previous month's last date
const previousMonth = currentMonth === 0 ? 11 : currentMonth - 1; // Adjust for January
const previousYear = currentMonth === 0 ? currentYear - 1 : currentYear; // Subtract one year if current month is January
const previousMonthLastDate = new Date(
currentYear,
currentMonth,
0
).getDate();

// Calculate the current month's end date
const currentMonthEndDate = new Date(
currentYear,
currentMonth + 1,
previousYear,
previousMonth + 1,
0
).getDate();

// Format the dates as strings in the "YYYY-MM-DD" format
const previousMonthLastDateString =
currentYear +
previousYear +
'-' +
currentMonth.toString().padStart(2, '0') +
(previousMonth + 1).toString().padStart(2, '0') +
'-' +
previousMonthLastDate.toString().padStart(2, '0');
const currentMonthEndDateString = currentEndDate;
Expand Down
Loading

0 comments on commit 873f80c

Please sign in to comment.