#include <includes.h>
#include "time.h"
#include "fattime.h"

DWORD get_fattime (void)
{
    TRTC_Data rtc_time;
    union
    {
        struct
        {
            uint16_t sec_2:  5;
            uint16_t min:    6;
            uint16_t hour:   5;
            uint16_t day:    5;
            uint16_t month:  4;
            uint16_t year:   7;
        } time_bf;
        DWORD un;
    } time;
        
    Sec2Date(&rtc_time, GetTimeSec());
    
    if ((rtc_time.year >= 70) && (rtc_time.year < 80))
    {
         rtc_time.year = 80;
    }
    if (rtc_time.year >= 80) time.time_bf.year = rtc_time.year - 80;
    else time.time_bf.year = rtc_time.year + 20;

    time.time_bf.day =  rtc_time.day; 
    time.time_bf.month = rtc_time.mon; 
    time.time_bf.hour = rtc_time.hour; 
    time.time_bf.min = rtc_time.min; 
    time.time_bf.sec_2 = rtc_time.sec/2; 
    
    return time.un;
}

