Skip to content
This repository has been archived by the owner on Oct 5, 2019. It is now read-only.

initial time model - use plugins format #173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/ng2-datetime/ng2-datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,8 @@ export class NKDatetime implements ControlValueAccessor, AfterViewInit, OnDestro

// update timepicker
if (this.timepicker !== undefined && isDate(date)) {
let hours = date.getHours();
if (this.timepickerOptions.showMeridian) {
// Convert 24 to 12 hour system
hours = (hours === 0 || hours === 12) ? 12 : hours % 12;
}
const meridian = date.getHours() >= 12 ? ' PM' : ' AM';
const time =
this.pad(hours) + ':' +
this.pad(this.date.getMinutes()) + ':' +
this.pad(this.date.getSeconds()) +
(this.timepickerOptions.showMeridian || this.timepickerOptions.showMeridian === undefined
? meridian : '');
this.timepicker.timepicker('setTime', time);
this.timeModel = time; // fix initial empty timeModel bug
this.timepicker.timepicker('setTime', date);
this.timeModel = this.timepicker.data('timepicker').getTime(); // fix initial empty timeModel bug
}
}

Expand Down