Rev 9260 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9765 | turbocat | 1 | #include |
8787 | turbocat | 2 | #include |
3 | |||
9765 | turbocat | 4 | time_t time(time_t* timer) |
5 | { |
||
9260 | turbocat | 6 | static struct tm __buffertime; |
8787 | turbocat | 7 | int kos_date, kos_time; |
9093 | turbocat | 8 | kos_date = _ksys_get_date().val; |
9094 | turbocat | 9 | kos_time = _ksys_get_time().val; |
9765 | turbocat | 10 | |
8787 | turbocat | 11 | int bcd_day = (kos_date >> 16); |
12 | int bcd_mon = ((kos_date & 0xFF00) >> 8); |
||
13 | int bcd_year = (kos_date & 0xFF); |
||
9765 | turbocat | 14 | __buffertime.tm_mday = ((bcd_day & 0xF0) >> 4) * 10 + (bcd_day & 0x0F); |
15 | __buffertime.tm_mon = ((bcd_mon & 0xF0) >> 4) * 10 + (bcd_mon & 0x0F) - 1; |
||
16 | __buffertime.tm_year = ((bcd_year & 0xF0) >> 4) * 10 + (bcd_year & 0x0F) + 100; |
||
17 | |||
8787 | turbocat | 18 | __buffertime.tm_wday = __buffertime.tm_yday = __buffertime.tm_isdst = -1; /* temporary */ |
9765 | turbocat | 19 | |
8787 | turbocat | 20 | int bcd_sec = (kos_time >> 16); |
21 | int bcd_min = ((kos_time & 0xFF00) >> 8); |
||
22 | int bcd_hour = (kos_time & 0xFF); |
||
9765 | turbocat | 23 | |
24 | __buffertime.tm_sec = ((bcd_sec & 0xF0) >> 4) * 10 + (bcd_sec & 0x0F); |
||
25 | __buffertime.tm_min = ((bcd_min & 0xF0) >> 4) * 10 + (bcd_min & 0x0F); |
||
26 | __buffertime.tm_hour = ((bcd_hour & 0xF0) >> 4) * 10 + (bcd_hour & 0x0F); |
||
27 | |||
8787 | turbocat | 28 | time_t ret = mktime(&__buffertime); |
9765 | turbocat | 29 | if (timer) { |
30 | *timer = ret; |
||
8787 | turbocat | 31 | } |
32 | return ret; |
||
9093 | turbocat | 33 | } |