From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tje8W-0002Cm-P2 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 17:53:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tje8V-0001j0-IG for qemu-devel@nongnu.org; Fri, 14 Dec 2012 17:53:44 -0500 Received: from mail-wi0-f171.google.com ([209.85.212.171]:40275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tje8V-0001iu-C3 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 17:53:43 -0500 Received: by mail-wi0-f171.google.com with SMTP id hn14so812086wib.10 for ; Fri, 14 Dec 2012 14:53:41 -0800 (PST) From: Antoine Mathys Date: Fri, 14 Dec 2012 23:53:27 +0100 Message-Id: <1355525607-2398-1-git-send-email-barsamin@gmail.com> Subject: [Qemu-devel] [PATCH] Fix conversion between 12 hours and 24 hours modes. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Antoine Mathys , peter.maydell@linaro.org, paul@codesourcery.com 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 --- 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