⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systime.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
字号:
/*
 * COPYRIGHT:   See COPYING in the top level directory
 * PROJECT:     ReactOS system libraries
 * FILE:        lib/crt/??????
 * PURPOSE:     Unknown
 * PROGRAMER:   Unknown
 * UPDATE HISTORY:
 *              25/11/05: Added license header
 */

#include <precomp.h>

int month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31};

/*
 * @unimplemented
 */
unsigned int _getsystime(struct tm* tp)
{
    SYSTEMTIME Time;
    int i;

    GetLocalTime(&Time);

    tp->tm_year = Time.wYear - 1900; 
    tp->tm_mon = Time.wMonth - 1; 
    tp->tm_wday = Time.wDayOfWeek; 
    tp->tm_mday = Time.wDay; 
    tp->tm_hour = Time.wHour; 
    tp->tm_min = Time.wMinute; 
    tp->tm_sec = Time.wSecond; 

    tp->tm_isdst = -1;

    //FIXME GetTimeZoneInformation currently not in kernel32

    //TimeZoneId =  GetTimeZoneInformation(&TimeZoneInformation );
    //if ( TimeZoneId == TIME_ZONE_ID_DAYLIGHT ) {
    //  tp->tm_isdst = 1;
    //}
    //else
    //  tp->tm_isdst = 0;

    if (tp->tm_year % 4 == 0) {
        if (tp->tm_year % 100 != 0)
            tp->tm_yday = 1;
        else if ((tp->tm_year-100) % 1000 == 0)
            tp->tm_yday = 1;
    }

    for (i = 0; i <= tp->tm_mon; i++)
        tp->tm_yday += month[i];
    
    return Time.wMilliseconds;
}


/*
 * @implemented
 */
unsigned int _setsystime(struct tm* tp, unsigned int ms)
{
    SYSTEMTIME Time;

    Time.wYear = tp->tm_year + 1900; 
    Time.wMonth = tp->tm_mon + 1; 
    Time.wDayOfWeek = tp->tm_wday; 
    Time.wDay = tp->tm_mday; 
    Time.wHour = tp->tm_hour; 
    Time.wMinute = tp->tm_min; 
    Time.wSecond = tp->tm_sec; 
    Time.wMilliseconds = ms;

    if (!SetLocalTime(&Time))
        return -1;

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -