Convert Ms unit + fun with approximative pipe

This commit is contained in:
2017-10-14 04:01:54 +02:00
parent 6034b79749
commit 778fb2d701
3 changed files with 7 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ import { ElsService } from './els.service';
import { AppRoutingModule } from './app-routing.module';
import { ConvertMsPipe } from './convertms.pipe';
import { ConvertMoreExactPipe } from './convert-more-exact.pipe';
import { SortByPipe } from './sort-by.pipe';
@NgModule({
@@ -28,6 +29,7 @@ import { SortByPipe } from './sort-by.pipe';
ArtistComponent,
GenreComponent,
ConvertMsPipe,
ConvertMoreExactPipe,
SortByPipe
],
providers: [

View File

@@ -23,10 +23,10 @@ export class ConvertMsPipe implements PipeTransform {
// Final string
let ret = '';
if (days > 0) { ret += ('0' + days).slice(-2) + ':'; }
if (hours > 0) { ret += ('0' + hours).slice(-2) + ':'; }
if (minutes > 0) { ret += ('0' + minutes).slice(-2) + ':'; }
if (seconds > 0) { ret += ('0' + seconds).slice(-2); }
if (days > 0) { ret += ('0' + days).slice(-2) + 'd'; }
if (hours > 0) { ret += ('0' + hours).slice(-2) + 'h'; }
if (minutes > 0) { ret += ('0' + minutes).slice(-2) + 'm'; }
if (seconds > 0) { ret += ('0' + seconds).slice(-2) + 's'; }
return ret;
// return ('0' + days).slice(-2) + ':' + ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2);

View File

@@ -15,7 +15,7 @@
<h3 *ngIf="!totalTime"><span class="glyphicon glyphicon-refresh loading"></span></h3>
<h3 *ngIf="totalTime">{{totalTime | convertMs}}</h3>
</div>
<div><br>Total time</div>
<div><br>Total time ({{totalTime | convertMoreExact}})</div>
</div>
</div>
</div>