summaryrefslogtreecommitdiff
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
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
-rw-r--r--components.c23
-rw-r--r--config.h3
2 files changed, 21 insertions, 5 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;
}
diff --git a/config.h b/config.h
index b006afd..a6b7039 100644
--- a/config.h
+++ b/config.h
@@ -23,6 +23,7 @@ enum flag
NORMALTIME = 1<<1,
BINARYTIME = 1<<2,
MILITARYTIME = 1<<3,
+ SHOWMERIDIEM = 1<<4,
};
struct component
@@ -37,7 +38,7 @@ struct component
*/
static const struct component components[] ={
/* function flag */
- {currenttime, NORMALTIME},
+ {currenttime, NORMALTIME|SHOWMERIDIEM},
{battery, 0},
{charging, 0},
};