X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fservices%2FSharedService.ts;fp=src%2Fservices%2FSharedService.ts;h=d35e41d3c047319378c1d1b4228f639b38367262;hb=09cd4ecd880a8c04282cc3388d37d559f07327a9;hp=41f3d76ada7aac5f32a1eea2f4bd2cafd0accad8;hpb=403234ed6120ba4bc01578b3ec237fa5fd4c0f6d;p=osm%2FNG-UI.git diff --git a/src/services/SharedService.ts b/src/services/SharedService.ts index 41f3d76..d35e41d 100644 --- a/src/services/SharedService.ts +++ b/src/services/SharedService.ts @@ -22,6 +22,7 @@ import { HttpErrorResponse, HttpHeaders } from '@angular/common/http'; import { EventEmitter, Injectable, Output } from '@angular/core'; import { FormArray, FormGroup } from '@angular/forms'; import { Router } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; import { CONSTANTNUMBER, ERRORDATA, GETAPIURLHEADER, PACKAGEINFO, PAGERSMARTTABLE, SMARTTABLECLASS, TARSETTINGS } from 'CommonModel'; import { environment } from 'environment'; import * as HttpStatus from 'http-status-codes'; @@ -100,24 +101,31 @@ export class SharedService { /** Check for the root directory @private */ private directoryCount: number = 2; - constructor(restService: RestService, router: Router) { + /** Contains tranlsate instance @private */ + private translateService: TranslateService; + + constructor(restService: RestService, router: Router, translateService: TranslateService) { this.restService = restService; this.router = router; + this.translateService = translateService; } /** convert epoch time function @public */ public convertEpochTime(unixtimestamp: number): string { - const monthsArr: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; - const date: Date = new Date(unixtimestamp * this.epochTime1000); - const year: number = date.getFullYear(); - const month: string = monthsArr[date.getMonth()]; - const day: number = date.getDate(); - const hours: number = date.getHours(); - const minutes: string = '0' + date.getMinutes(); - const seconds: string = '0' + date.getSeconds(); - return month + '-' + day + '-' + year + ' ' + hours + ':' + minutes.substr(this.epochTimeMinus2) + ':' - + seconds.substr(this.epochTimeMinus2); + if (!isNullOrUndefined(unixtimestamp)) { + const monthsArr: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + const date: Date = new Date(unixtimestamp * this.epochTime1000); + const year: number = date.getFullYear(); + const month: string = monthsArr[date.getMonth()]; + const day: number = date.getDate(); + const hours: number = date.getHours(); + const minutes: string = '0' + date.getMinutes(); + const seconds: string = '0' + date.getSeconds(); + return month + '-' + day + '-' + year + ' ' + hours + ':' + minutes.substr(this.epochTimeMinus2) + ':' + + seconds.substr(this.epochTimeMinus2); + } + return this.translateService.instant('NODATE'); } /** Download Files function @public */