Also format the "Automatic dark mode" clocks.
This commit is contained in:
parent
039264531f
commit
56d4a677a5
1 changed files with 7 additions and 3 deletions
|
@ -145,7 +145,11 @@ class SettingsPage extends React.PureComponent<Props, State> {
|
||||||
this.props.setDarkTime(value, options);
|
this.props.setDarkTime(value, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
to12Hour(time: string) {
|
formatHour(time: string, clock24h: boolean) {
|
||||||
|
if (clock24h) {
|
||||||
|
return `${time}:00`;
|
||||||
|
}
|
||||||
|
|
||||||
const now = new Date(0, 0, 0, Number(time));
|
const now = new Date(0, 0, 0, Number(time));
|
||||||
|
|
||||||
const hour = now.toLocaleTimeString('en-US', { hour12: true, hour: '2-digit' });
|
const hour = now.toLocaleTimeString('en-US', { hour12: true, hour: '2-digit' });
|
||||||
|
@ -292,7 +296,7 @@ class SettingsPage extends React.PureComponent<Props, State> {
|
||||||
>
|
>
|
||||||
{startHours.map((time) => (
|
{startHours.map((time) => (
|
||||||
<option key={time} value={time}>
|
<option key={time} value={time}>
|
||||||
{this.to12Hour(time)}
|
{this.formatHour(time, clock24h)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
@ -305,7 +309,7 @@ class SettingsPage extends React.PureComponent<Props, State> {
|
||||||
>
|
>
|
||||||
{endHours.map((time) => (
|
{endHours.map((time) => (
|
||||||
<option key={time} value={time}>
|
<option key={time} value={time}>
|
||||||
{this.to12Hour(time)}
|
{this.formatHour(time, clock24h)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
Loading…
Reference in a new issue