summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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},
};