回覆列表
  • 1 # 使用者8209154827005

    可以使用SYSTEMTIME型別

    typedef struct _SYSTEMTIME {

    WORD wYear;

    WORD wMonth;

    WORD wDayOfWeek;

    WORD wDay;

    WORD wHour;

    WORD wMinute;

    WORD wSecond;

    WORD wMilliseconds;

    } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;

    也可以使用time_t

    #ifndef _TIME32_T_DEFINED

    typedef _W64 long __time32_t; /* 32-bit time value */

    #define _TIME32_T_DEFINED

    #endif

    #ifndef _TIME64_T_DEFINED

    typedef __int64 __time64_t; /* 64-bit time value */

    #define _TIME64_T_DEFINED

    #endif

    #ifndef _TIME_T_DEFINED

    #ifdef _USE_32BIT_TIME_T

    typedef __time32_t time_t; /* time value */

    #else

    typedef __time64_t time_t; /* time value */

    #endif

    #define _TIME_T_DEFINED /* avoid multiple def"s of time_t */

    #endif

    還有其它型別,當然,你也可以自己定義一個日期型別,比如,我就是自己定義瞭如下型別:

    //Only for C++

    typedef struct tagGDATE{

    signed short sYear;//年(公曆)

    unsigned short wMonth;//月(公曆)

    unsigned short wDay;//日(公曆)

    unsigned short wDayOfWeek;//星期

    tagGDATE() : sYear(0), wMonth(0), wDay(0), wDayOfWeek(0){}

    }GDATE,*PGDATE,LPGDATE;//公曆日期

    typedef struct tagTIME{

    unsigned short wHour;//時

    unsigned short wMinute;//分

    unsigned short wSecond;//秒

    unsigned short wMillisecond;//毫秒

    tagTIME() : wHour(0) ,wMinute(0), wSecond(0), wMillisecond(0){}

    }TIME,*PTIME;//時間

    typedef struct tagDATETIME : GDATE , TIME{

    }DATETIME,*PDATETIME,LPDATETIME;//公曆日期時間

  • 中秋節和大豐收的關聯?
  • 恆大亞冠被浦和紅鑽淘汰了。菜卡會下課嗎?