Fix time until component round for week interval. (#679)
* Fix time until component round for week interval. * Add forceFloorOnTimeIntervals parameter.
This commit is contained in:
		
							parent
							
								
									0293ba4a52
								
							
						
					
					
						commit
						a0559cbb24
					
				| @ -21,7 +21,7 @@ | ||||
|               <app-time-until [time]="(1 * i) + now + 61000" [fastRender]="false" [fixedRender]="true"></app-time-until> | ||||
|             </ng-template> | ||||
|             <ng-template #timeDiffMainnet> | ||||
|               <app-time-until [time]="(timeAvg * i) + now + timeAvg" [fastRender]="false" [fixedRender]="true"></app-time-until> | ||||
|               <app-time-until [time]="(timeAvg * i) + now + timeAvg" [fastRender]="false" [fixedRender]="true" [forceFloorOnTimeIntervals]="['hour']"></app-time-until> | ||||
|             </ng-template> | ||||
|           </div> | ||||
|           <ng-template #mergedBlock> | ||||
|  | ||||
| @ -15,6 +15,7 @@ export class TimeUntilComponent implements OnInit, OnChanges, OnDestroy { | ||||
|   @Input() time: number; | ||||
|   @Input() fastRender = false; | ||||
|   @Input() fixedRender = false; | ||||
|   @Input() forceFloorOnTimeIntervals: string[]; | ||||
| 
 | ||||
|   constructor( | ||||
|     private ref: ChangeDetectorRef, | ||||
| @ -67,10 +68,10 @@ export class TimeUntilComponent implements OnInit, OnChanges, OnDestroy { | ||||
|     let counter: number; | ||||
|     for (const i in this.intervals) { | ||||
|       if (this.intervals.hasOwnProperty(i)) { | ||||
|         if (i === 'minute') { | ||||
|           counter = Math.round(seconds / this.intervals[i]); | ||||
|         } else { | ||||
|         if (this.forceFloorOnTimeIntervals && this.forceFloorOnTimeIntervals.indexOf(i) > -1) { | ||||
|           counter = Math.floor(seconds / this.intervals[i]); | ||||
|         } else { | ||||
|           counter = Math.round(seconds / this.intervals[i]); | ||||
|         } | ||||
|         const dateStrings = dates(counter); | ||||
|         if (counter > 0) { | ||||
|  | ||||
| @ -120,7 +120,7 @@ | ||||
|                           <app-time-until [time]="(60 * 1000 * txInBlockIndex) + now" [fastRender]="false" [fixedRender]="true"></app-time-until> | ||||
|                         </ng-template> | ||||
|                         <ng-template #timeEstimateDefault> | ||||
|                           <app-time-until *ngIf="(timeAvg$ | async) as timeAvg;" [time]="(timeAvg * txInBlockIndex) + now + timeAvg" [fastRender]="false" [fixedRender]="true"></app-time-until> | ||||
|                           <app-time-until *ngIf="(timeAvg$ | async) as timeAvg;" [time]="(timeAvg * txInBlockIndex) + now + timeAvg" [fastRender]="false" [fixedRender]="true" [forceFloorOnTimeIntervals]="['hour']"></app-time-until> | ||||
|                         </ng-template> | ||||
|                       </ng-template> | ||||
|                     </ng-template> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user