Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
add 12h clock option
Browse files Browse the repository at this point in the history
  • Loading branch information
galister committed Sep 1, 2023
1 parent b891192 commit b7670f4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Overlays/Watch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ public Watch(BaseOverlay keyboard) : base("Watch")

Canvas.CurrentFgColor = HexColor.FromRgb("#FFFFFF");

var timeFormat = Config.Instance.Use12hTime ? "hh:mm" : "HH:mm";

Canvas.CurrentFont = FontCollection.Get(46, FontStyle.Bold);
_canvas.AddControl(new DateTimeLabel("HH:mm", TimeZoneInfo.Local, 19, 107, 200, 50));
_canvas.AddControl(new DateTimeLabel(timeFormat, TimeZoneInfo.Local, 19, 107, 200, 50));

Canvas.CurrentFont = FontCollection.Get(14, FontStyle.Bold);
_canvas.AddControl(new DateTimeLabel("d", TimeZoneInfo.Local, 20, 80, 200, 50));
_canvas.AddControl(new DateTimeLabel("dddd", TimeZoneInfo.Local, 20, 60, 200, 50));
if (Config.Instance.Use12hTime)
_canvas.AddControl(new DateTimeLabel("tt", TimeZoneInfo.Local, 175, 107, 200, 50));

if (Config.Instance.AltTimezone1 != null)
{
Expand All @@ -72,9 +76,13 @@ public Watch(BaseOverlay keyboard) : base("Watch")

Canvas.CurrentFont = FontCollection.Get(14, FontStyle.Bold);
_canvas.AddControl(new Label(tzDisplay, 210, 137, 200, 50));
if (Config.Instance.Use12hTime) {
Canvas.CurrentFont = FontCollection.Get(9, FontStyle.Bold);
_canvas.AddControl(new DateTimeLabel("tt", tz, 294, 107, 200, 50));
}

Canvas.CurrentFont = FontCollection.Get(24, FontStyle.Bold);
_canvas.AddControl(new DateTimeLabel("HH:mm", tz, 210, 107, 200, 50));
_canvas.AddControl(new DateTimeLabel(timeFormat, tz, 210, 107, 200, 50));
}

if (Config.Instance.AltTimezone2 != null)
Expand All @@ -85,9 +93,13 @@ public Watch(BaseOverlay keyboard) : base("Watch")

Canvas.CurrentFont = FontCollection.Get(14, FontStyle.Bold);
_canvas.AddControl(new Label(tzDisplay, 210, 82, 200, 50));
if (Config.Instance.Use12hTime) {
Canvas.CurrentFont = FontCollection.Get(9, FontStyle.Bold);
_canvas.AddControl(new DateTimeLabel("tt", tz, 294, 52, 200, 50));
}

Canvas.CurrentFont = FontCollection.Get(24, FontStyle.Bold);
_canvas.AddControl(new DateTimeLabel("HH:mm", tz, 210, 52, 200, 50));
_canvas.AddControl(new DateTimeLabel(timeFormat, tz, 210, 52, 200, 50));
}

// Volume controls
Expand Down
3 changes: 3 additions & 0 deletions Resources/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ keyboard_volume: 1.0
## 0 to disable. default: 0.1
keyboard_haptics: 0.1

## 12-hour format
#use_12h_time: true

## additional timezones to display, other than your local time. optional.
alt_timezone1: Asia/Tokyo
alt_timezone2: America/Chicago
Expand Down
4 changes: 4 additions & 0 deletions Types/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public static bool Load()
public string[]? VolumeUpCmd;
public string[]? VolumeDnCmd;

// work around case conversion issue
public bool use_12h_time;
public bool Use12hTime => use_12h_time;

public string? AltTimezone1;
public string? AltTimezone2;

Expand Down

0 comments on commit b7670f4

Please sign in to comment.