summaryrefslogtreecommitdiff
path: root/components.c
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2019-12-12 00:23:42 +1030
committerDaniel Jones <admin@danieljon.es>2019-12-12 00:26:22 +1030
commit797fd1710f2f1ea082bf111f2c930c7c36cb59b4 (patch)
tree64d55056850ae58418f4ee3a757eb99ab74e2b51 /components.c
parent7ed46f531ccf25db7edb980cfb0910d6a63f38b9 (diff)
downloadbinstatus-797fd1710f2f1ea082bf111f2c930c7c36cb59b4.tar.gz
binstatus-797fd1710f2f1ea082bf111f2c930c7c36cb59b4.zip
added meridem flag
you can now toggle whether to show the meridem tag on each clock you configure
Diffstat (limited to 'components.c')
-rw-r--r--components.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/components.c b/components.c
index 09c1fc0..8244432 100644
--- a/components.c
+++ b/components.c
@@ -52,21 +52,36 @@ converthour(int hour)
char *currenttime(char *store, size_t size, int flag)
{
int time[2];
+ char meridiem[3];
gettime(time);
+ if (flag & SHOWMERIDIEM)
+ {
+ meridiem[1] = 'M';
+ meridiem[2] = '\0';
+ if (time[0] < 12)
+ meridiem[0] = 'A';
+ else
+ meridiem[0] = 'P';
+
+ }
if (flag & NORMALTIME)
{
- if (time[0] > 12)
+ if (time[0] == 0)
+ time[0] = 12;
+ else if (time[0] > 12)
time[0] = converthour(time[0]);
}
if (flag & BINARYTIME)
{
- snprintf(store, size, "%05d:%05d ", dectobin(time[0]),
- dectobin(time[1]));
+ snprintf(store, size, "%05d:%05d %s ", dectobin(time[0]),
+ dectobin(time[1]),
+ meridiem);
}
/* military time is the default, so we need not do anything */
else
{
- snprintf(store, size, "%02d:%02d ", time[0], time[1]);
+ snprintf(store, size, "%02d:%02d %s ", time[0], time[1],
+ meridiem);
}
return store;
}