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;
|
||||
let startDate = new Date(this.jobResult.startDate);
|
||||
let endDate = this.jobResult.endDate ? new Date(this.jobResult.endDate) : new Date();
|
||||
|
||||
this.jobDuration = new Duration();
|
||||
this.jobDuration.years = endDate.getFullYear() - startDate.getFullYear();
|
||||
this.jobDuration.months = endDate.getMonth() - startDate.getMonth();
|
||||
this.jobDuration.days = endDate.getDate() - startDate.getDate();
|
||||
this.jobDuration.hours = endDate.getHours() - startDate.getHours();
|
||||
this.jobDuration.minutes = endDate.getMinutes() - startDate.getMinutes();
|
||||
this.jobDuration.seconds = endDate.getSeconds() - startDate.getSeconds();
|
||||
console.log(this.jobDuration);
|
||||
const msBetweenDates = endDate.getTime() - startDate.getTime();
|
||||
this.jobDuration.seconds = Math.ceil(msBetweenDates / 1000 % 60);
|
||||
this.jobDuration.minutes = Math.floor(msBetweenDates / 1000 / 60 % 60);
|
||||
this.jobDuration.hours = Math.floor(msBetweenDates / 1000 / 60 / 60 % 24);
|
||||
this.jobDuration.days = Math.floor(msBetweenDates / 1000 / 60 / 60 / 24);
|
||||
this.jobDuration.months = Math.floor(this.jobDuration.days / 31);
|
||||
this.jobDuration.years = Math.floor(this.jobDuration.months / 12);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue