Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Optimization changes
  • Loading branch information
MarcoAguirre committed May 4, 2022
commit 26f16a173f422289e1933874cef94ea19d1f0f89
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('Reports Page', () => {

it('Should populate the users with the payload from the action executed', () => {
const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject;
const usersArray = []
const usersArray = [];
const action = {
type: UserActionTypes.LOAD_USERS_SUCCESS,
payload: usersArray
Expand All @@ -203,8 +203,8 @@ describe('Reports Page', () => {
});

it('The sum of the data dates is equal to {"hours": 3, "minutes":20,"seconds":0}', () => {
let {hours,minutes,seconds}: TotalHours = component.sumDates(timeEntryList);
expect({hours, minutes, seconds}).toEqual({hours:3,minutes:20,seconds:0});
let { hours, minutes, seconds }: TotalHours = component.sumDates(timeEntryList);
expect({ hours, minutes, seconds }).toEqual({ hours: 3, minutes: 20, seconds: 0 });
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
const durationColumnIndex = 3;
return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated;
}

sumDates(arrayData: Entry[]): TotalHours{
this.resultSum = new TotalHours();
let arrayDurations= new Array();
arrayData.forEach(entry =>{
let start = moment(entry.end_date).diff(moment(entry.start_date));
arrayDurations.push(moment.utc(start).format("HH:mm:ss"));
let arrayDurations = new Array();
arrayData.forEach(entry => {
const start = moment(entry.end_date).diff(moment(entry.start_date));
arrayDurations.push(moment.utc(start).format('HH:mm:ss'));
});

let totalDurations = arrayDurations.slice(1)
Expand All @@ -142,7 +142,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
},
moment.duration(arrayDurations[0]));
let daysInHours = totalDurations.days() * 24;
this.resultSum.hours=totalDurations.hours() + daysInHours;
this.resultSum.hours = totalDurations.hours() + daysInHours;
this.resultSum.minutes = totalDurations.minutes();
this.resultSum.seconds = totalDurations.seconds();
return this.resultSum;
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/reports/models/total-hours-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export class TotalHours {
this.minutes = 0;
this.seconds = 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import * as moment from 'moment';

export class ParseDateTimeOffset {

parseDateTimeOffset(date:string, offset): string{
if(date == null || date == undefined || date == '') return 'In progress';
return moment.utc(date).utcOffset(-1*offset).format("HH:mm");
parseDateTimeOffset(date: string, offset: any): string {
if (date === null || date === undefined || date === '') return 'In progress';

return moment
.utc(date)
.utcOffset(-1 * offset)
.format('HH:mm');
}
}