* [Qemu-devel] [PATCH] Fix conversion between 12 hours and 24 hours modes.
@ 2012-12-14 22:53 Antoine Mathys
0 siblings, 0 replies; only message in thread
From: Antoine Mathys @ 2012-12-14 22:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Antoine Mathys, peter.maydell, paul
The proper mapping between 24 hours and 12 hours modes is:
0 12 AM
1-11 1-11 AM
12 12 PM
13-23 1-11 PM
Fix code accordingly.
Signed-off-by: Antoine Mathys <barsamin@gmail.com>
---
hw/ds1338.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/ds1338.c b/hw/ds1338.c
index 1aefa3b..9e6b490 100644
--- a/hw/ds1338.c
+++ b/hw/ds1338.c
@@ -59,8 +59,8 @@ static void capture_current_time(DS1338State *s)
s->nvram[1] = to_bcd(now.tm_min);
if (s->nvram[2] & HOURS_12) {
int tmp = now.tm_hour;
- if (tmp == 0) {
- tmp = 24;
+ if (tmp % 12 == 0) {
+ tmp += 12;
}
if (tmp <= 12) {
s->nvram[2] = HOURS_12 | to_bcd(tmp);
@@ -145,8 +145,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
if (data & HOURS_PM) {
tmp += 12;
}
- if (tmp == 24) {
- tmp = 0;
+ if (tmp % 12 == 0) {
+ tmp -= 12;
}
now.tm_hour = tmp;
} else {
--
1.7.10.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-12-14 22:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-14 22:53 [Qemu-devel] [PATCH] Fix conversion between 12 hours and 24 hours modes Antoine Mathys
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).