Add default unitScale
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
bb555eec74
commit
b17bce1cd2
@ -64,12 +64,21 @@ export class TimespanService {
|
||||
return this.getStartEndCaption(new Date(endDate.getTime() - (this.unitScales[unitScale] / 2)), startDate, unitScale, suffix);
|
||||
}
|
||||
|
||||
getCaption(startDate: Date, endDate: Date, unitScale: number): string {
|
||||
let startCaption = this.getStartCaption(startDate, endDate, unitScale);
|
||||
let endCaption = this.getEndCaption(startDate,endDate, unitScale);
|
||||
if ((endDate.getTime() - startDate.getTime()) < (1.5 * this.unitScales[unitScale]))
|
||||
getCaption(startDate: Date, endDate: Date, unitScale?: number): string {
|
||||
let scale = unitScale;
|
||||
if(unitScale==null) {
|
||||
scale=4;
|
||||
if(startDate.getUTCMonth() == 0 && startDate.getUTCDate() == 1 && startDate.getUTCHours() == 0 && startDate.getUTCMinutes() ==0 && startDate.getUTCSeconds() ==0 &&
|
||||
endDate.getUTCMonth() == 0 && endDate.getUTCDate() == 1 && endDate.getUTCHours() == 0 && endDate.getUTCMinutes() ==0 && endDate.getUTCSeconds() ==0) {
|
||||
scale=8;
|
||||
} else if (startDate.getUTCHours() > 0 && startDate.getUTCMinutes() >0) {
|
||||
scale =3
|
||||
}
|
||||
}
|
||||
let startCaption = this.getStartCaption(startDate, endDate, scale);
|
||||
let endCaption = this.getEndCaption(startDate,endDate, scale);
|
||||
if ((endDate.getTime() - startDate.getTime()) < (1.5 * this.unitScales[scale]))
|
||||
return endCaption;
|
||||
return `${startCaption}-${endCaption}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user