aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAntoine Mathys <barsamin@gmail.com>2013-02-28 18:23:12 +0000
committerPeter Maydell <peter.maydell@linaro.org>2013-02-28 18:23:12 +0000
commit5c78d6a84b504e831adc8f1917cde0c79061dff0 (patch)
tree8ee0167489766d5753d7febee000470e35092b19 /hw
parenta4bcea3d67949c6be45992bd5092a19f163bcd4e (diff)
hw/ds1338: Fix conversion between 12 hours and 24 hours modes.
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> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/ds1338.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/hw/ds1338.c b/hw/ds1338.c
index 6f70538eb3..1da0f96fdc 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 {