summaryrefslogtreecommitdiffstats
path: root/clock.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2013-04-11 21:52:18 +0000
committerNicholas Marriott <nicm@openbsd.org>2013-04-11 21:52:18 +0000
commit7f9b225cc269211b86a4c4d2168146c217d63118 (patch)
treef37737f75081824502d3dd12a47ad67883f06ced /clock.c
parentcbee283c26968304b473e2191d2bb5f52208b58d (diff)
Call setlocale(LC_TIME) at startup.
Diffstat (limited to 'clock.c')
-rw-r--r--clock.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/clock.c b/clock.c
index 00d818be..283a4a1e 100644
--- a/clock.c
+++ b/clock.c
@@ -103,13 +103,20 @@ clock_draw(struct screen_write_ctx *ctx, int colour, int style)
struct grid_cell gc;
char tim[64], *ptr;
time_t t;
+ struct tm *tm;
u_int i, j, x, y, idx;
t = time(NULL);
- if (style == 0)
- strftime(tim, sizeof tim, "%l:%M %p", localtime(&t));
- else
- strftime(tim, sizeof tim, "%H:%M", localtime(&t));
+ tm = localtime(&t);
+ if (style == 0) {
+ strftime(tim, sizeof tim, "%l:%M ", localtime(&t));
+ if (tm->tm_hour >= 12)
+ strlcat(tim, "PM", sizeof tim);
+ else
+ strlcat(tim, "AM", sizeof tim);
+ } else
+ strftime(tim, sizeof tim, "%H:%M", tm);
+
screen_write_clearscreen(ctx);