Subversion Repositories Kolibri OS

Rev

Rev 9093 | Rev 9260 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8787 turbocat 1
#include 
2
#include 
3
 
4
static struct tm __buffertime;
5
 
6
time_t time(time_t *timer){
7
    int kos_date, kos_time;
9093 turbocat 8
    kos_date = _ksys_get_date().val;
9094 turbocat 9
    kos_time = _ksys_get_time().val;
8787 turbocat 10
 
11
    int bcd_day = (kos_date >> 16);
12
    int bcd_mon = ((kos_date & 0xFF00) >> 8);
13
    int bcd_year = (kos_date & 0xFF);
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
 
18
    __buffertime.tm_wday = __buffertime.tm_yday = __buffertime.tm_isdst = -1; /* temporary */
19
 
20
    int bcd_sec = (kos_time >> 16);
21
    int bcd_min = ((kos_time & 0xFF00) >> 8);
22
    int bcd_hour = (kos_time & 0xFF);
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
 
28
    time_t ret = mktime(&__buffertime);
29
    if(timer){
30
        *timer=ret;
31
    }
32
 
33
    return ret;
9093 turbocat 34
}