oaipmh-analysis.component.ts: [Bug fix] Updated how job duration is calculated - negative numbers appeared.
This commit is contained in:
parent
32078e8732
commit
17023974f2
|
@ -162,14 +162,15 @@ export class OaipmhAnalysisComponent implements OnInit {
|
||||||
this.jobResult = result;
|
this.jobResult = result;
|
||||||
let startDate = new Date(this.jobResult.startDate);
|
let startDate = new Date(this.jobResult.startDate);
|
||||||
let endDate = this.jobResult.endDate ? new Date(this.jobResult.endDate) : new Date();
|
let endDate = this.jobResult.endDate ? new Date(this.jobResult.endDate) : new Date();
|
||||||
|
|
||||||
this.jobDuration = new Duration();
|
this.jobDuration = new Duration();
|
||||||
this.jobDuration.years = endDate.getFullYear() - startDate.getFullYear();
|
const msBetweenDates = endDate.getTime() - startDate.getTime();
|
||||||
this.jobDuration.months = endDate.getMonth() - startDate.getMonth();
|
this.jobDuration.seconds = Math.ceil(msBetweenDates / 1000 % 60);
|
||||||
this.jobDuration.days = endDate.getDate() - startDate.getDate();
|
this.jobDuration.minutes = Math.floor(msBetweenDates / 1000 / 60 % 60);
|
||||||
this.jobDuration.hours = endDate.getHours() - startDate.getHours();
|
this.jobDuration.hours = Math.floor(msBetweenDates / 1000 / 60 / 60 % 24);
|
||||||
this.jobDuration.minutes = endDate.getMinutes() - startDate.getMinutes();
|
this.jobDuration.days = Math.floor(msBetweenDates / 1000 / 60 / 60 / 24);
|
||||||
this.jobDuration.seconds = endDate.getSeconds() - startDate.getSeconds();
|
this.jobDuration.months = Math.floor(this.jobDuration.days / 31);
|
||||||
console.log(this.jobDuration);
|
this.jobDuration.years = Math.floor(this.jobDuration.months / 12);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue