mirror of
https://github.com/GeorgeSG/lovelace-time-picker-card.git
synced 2026-11-05 12:18:45 +00:00
Add optional seconds picker
This commit is contained in:
+17
-3
@@ -1,9 +1,15 @@
|
||||
import { Direction } from '../types';
|
||||
import { Hour } from './hour';
|
||||
import { Minute } from './minute';
|
||||
import { Direction } from '../types';
|
||||
import { Second } from './second';
|
||||
|
||||
export class Time {
|
||||
constructor(public hour: Hour, public minute: Minute, private _linkValues: boolean = false) {}
|
||||
constructor(
|
||||
public hour: Hour,
|
||||
public minute: Minute,
|
||||
public second: Second,
|
||||
private _linkValues: boolean = false
|
||||
) {}
|
||||
|
||||
hourStep(direction: Direction): void {
|
||||
this.hour.stepUpdate(direction);
|
||||
@@ -17,7 +23,15 @@ export class Time {
|
||||
this.minute.stepUpdate(direction);
|
||||
}
|
||||
|
||||
secondStep(direction: Direction): void {
|
||||
if (this._linkValues && this.second.willOverflow(direction)) {
|
||||
this.minute.stepUpdate(direction, 1);
|
||||
}
|
||||
|
||||
this.second.stepUpdate(direction);
|
||||
}
|
||||
|
||||
get value(): string {
|
||||
return `${this.hour.value}:${this.minute.value}`;
|
||||
return `${this.hour.value}:${this.minute.value}:${this.second.value}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user