mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-20 19:24:53 +00:00
bigclock: add 12-hour & seconds support (#805)
Added P,A,M characters to bigclock and added 12hr and seconds support to bigclock via `bigclock_12hr` and `bigclock_seconds` in the config.  Image has bigclock_12hr and bigclock_seconds enabled. Farsi characters for P,A,M are blank since I don't know what it would look like in their language. (should i have just used the english characters as a placeholder?) Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/805 Reviewed-by: AnErrupTion <anerruption@disroot.org> Co-authored-by: RadsammyT <radsammyt@gmail.com> Co-committed-by: RadsammyT <radsammyt@gmail.com>
This commit is contained in:
12
src/main.zig
12
src/main.zig
@@ -482,11 +482,19 @@ pub fn main() !void {
|
||||
}
|
||||
|
||||
if (config.bigclock != .none and buffer.box_height + (bigclock.HEIGHT + 2) * 2 < buffer.height) {
|
||||
const format = "%H:%M";
|
||||
var format_buf: [16:0]u8 = undefined;
|
||||
var clock_buf: [32:0]u8 = undefined;
|
||||
// We need the slice/c-string returned by `bufPrintZ`.
|
||||
const format: [:0]const u8 = try std.fmt.bufPrintZ(&format_buf, "{s}{s}{s}{s}",
|
||||
.{
|
||||
if (config.bigclock_12hr) "%I" else "%H",
|
||||
":%M",
|
||||
if (config.bigclock_seconds) ":%S" else "",
|
||||
if (config.bigclock_12hr) "%P" else ""
|
||||
});
|
||||
const xo = buffer.width / 2 - @min(buffer.width, (format.len * (bigclock.WIDTH + 1))) / 2;
|
||||
const yo = (buffer.height - buffer.box_height) / 2 - bigclock.HEIGHT - 2;
|
||||
|
||||
var clock_buf: [format.len + 1:0]u8 = undefined;
|
||||
const clock_str = interop.timeAsString(&clock_buf, format);
|
||||
|
||||
for (clock_str, 0..) |c, i| {
|
||||
|
||||
Reference in New Issue
Block a user