import { Component } from '@angular/core' ; import { NavController , ViewController } from 'ionic-angular' ; import { ScanSessionModel } from '../../../models/scan-session.model' ; @ Component ( { selector : 'page-edit-scan-session' , templateUrl : 'edit-scan-session.html' } ) export class EditScanSessionPage { public scanSession : ScanSessionModel ; public date : string ; private static timezoneOffset = new Date ( ) . getTimezoneOffset ( ) * 60000 ; constructor ( public viewCtrl , public navCtrl ) { this . scanSession = viewCtrl . getNavParams ( ) . data ; this . date = ( new Date ( this . scanSession . date - EditScanSessionPage . timezoneOffset ) ) . toISOString ( ) . slice ( 0 , - 1 ) ; } ionViewDidLoad ( ) { } dismiss ( ) { this . scanSession . date = this . convertDatePickerToTimestamp ( ) ; this . viewCtrl . dismiss ( this . scanSession ) ; } convertDatePickerToTimestamp ( ) { let d = new Date ( Date . parse ( this . date ) ) . getTime ( ) ; return new Date ( d + EditScanSessionPage . timezoneOffset ) . getTime ( ) ; } }