mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
40 lines
850 B
TypeScript
40 lines
850 B
TypeScript
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'app-timestamp-timepicker',
|
|
templateUrl: './timepicker.component.html',
|
|
})
|
|
export class TimeStampTimePickerComponent {
|
|
|
|
timestampValue = 0;
|
|
timezoneOffset = (new Date()).getTimezoneOffset() * 60 * 1000;
|
|
@Output() timestampChange = new EventEmitter<number>();
|
|
|
|
date: Date = new Date();
|
|
|
|
@Input() name: string;
|
|
|
|
@Input()
|
|
public get timestamp() {
|
|
return this.timestampValue;
|
|
}
|
|
|
|
public set timestamp(val: number) {
|
|
this.date.setTime(val + this.timezoneOffset);
|
|
if (this.timestampValue === val) {
|
|
return;
|
|
}
|
|
this.timestampValue = val;
|
|
this.timestampChange.emit(this.timestampValue);
|
|
}
|
|
|
|
onChange(date: Date | string): void {
|
|
this.timestamp = (new Date(date)).getTime() - this.timezoneOffset;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|