Thread (3 messages) 3 messages, 2 authors, 2012-06-12

confusion about reading time from cmos

From: Vladimir Murzin <hidden>
Date: 2012-06-12 07:56:18

Hi!

It seems that your CMOS count time in UTC. So, If CST stands for China
Standart Time then time zone offset: UTC + 8 hours ;)

Best wishes
Vladimir Murzin

On 6/12/12, ?? [off-list ref] wrote:
Hello everyone:

env:
Ubuntu 11.04

I write a program reading time from cmos,and the program is as followed:

#include <stdio.h>
#include <sys/io.h>

unsigned char cmos_read(unsigned char addr)
{
    unsigned char tmp = 0;
    iopl(3);
    outb(addr,0x70);
    tmp = inb(0x71);
    iopl(0);
    return tmp;
}


int main(void)
{
    printf("seconds = %x\n",cmos_read(0));
    printf("minute = %x\n",cmos_read(2));
    printf("hour = %x\n",cmos_read(4));
    system("date");
    return 0;
}


and run the program and the result is as followed:

wanny at wanny-C-Notebook-XXXX:~$ sudo ./a.out
seconds = 9
minute = 42
hour = 7
2012? 06? 12? ??? 15:42:09 CST

question:
why the second is right,minute is right , but the hour is different?

Thanks in advance!!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help