Skip to content

Commit

Permalink
Merge branch 'AMPATH:master' into POC-524-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykorir authored Feb 15, 2024
2 parents 5a6f1fd + 51d4206 commit 3c27276
Show file tree
Hide file tree
Showing 21 changed files with 555 additions and 132 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 3c27276

Please sign in to comment.