首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

怎么将这个数130202624596250000转成2013-08-06 11:34:19

2013-09-07 
如何将这个数130202624596250000转成2013-08-06 11:34:19如何将这个数130202624596250000转成2013-08-06 1

如何将这个数130202624596250000转成2013-08-06 11:34:19
如何将这个数130202624596250000转成2013-08-06 11:34:19

已知这是一个相对于1601年1月1日的、精确度是千万分之一秒的值。

我想知道有没有这样一个函数,直接将得到的数值转换成具体时间。
[解决办法]
为了减少循环
先算1601年1月1日的到1990年1月1日中间有多少秒,

然后用上面的数减去中间的秒数,剩余的时间就可以用库函数了
[解决办法]
FILETIME
The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601. 

typedef struct _FILETIME { // ft 
    DWORD dwLowDateTime; 
    DWORD dwHighDateTime; 
} FILETIME; 
 
Members
dwLowDateTime 
Specifies the low-order 32 bits of the file time. 
dwHighDateTime 
Specifies the high-order 32 bits of the file time. 
Remarks
It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should 

Copy the resulting FILETIME structure to a LARGE_INTEGER structure. 
Use normal 64-bit arithmetic on the LARGE_INTEGER value. 
QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winbase.h.

See Also
Time Overview, Time Structures, CompareFileTime, GetFileTime, LARGE_INTEGER 

 

[解决办法]
FileTimeToSystemTime
The FileTimeToSystemTime function converts a 64-bit file time to system time format. 

BOOL FileTimeToSystemTime(
  CONST FILETIME *lpFileTime,  // pointer to file time to convert


  LPSYSTEMTIME lpSystemTime    // pointer to structure to receive 
                               // system time
);
 
Parameters
lpFileTime 
Pointer to a FILETIME structure containing the file time to convert to system date and time format. 
The FileTimeToSystemTime function only works with FILETIME values that are less than 0x8000000000000000. The function fails with values equal to or greater than that. 

lpSystemTime 
Pointer to a SYSTEMTIME structure to receive the converted file time. 
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError. 

Remarks
As noted above, the function fails for FILETIME values that are equal to or greater than 0x8000000000000000. 

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.

See Also
Time Overview, Time Functions, DosDateTimeToFileTime, FILETIME, FileTimeToDosDateTime, SYSTEMTIME, SystemTimeToFileTime 

 
SYSTEMTIME
The SYSTEMTIME structure represents a date and time using individual members for the month, day, year, weekday, hour, minute, second, and millisecond. 

typedef struct _SYSTEMTIME {  // st 
    WORD wYear; 
    WORD wMonth; 
    WORD wDayOfWeek; 
    WORD wDay; 
    WORD wHour; 
    WORD wMinute; 
    WORD wSecond; 
    WORD wMilliseconds; 
} SYSTEMTIME; 


 
Members
wYear 
Specifies the current year. 
wMonth 
Specifies the current month; January = 1, February = 2, and so on. 
wDayOfWeek 
Specifies the current day of the week; Sunday = 0, Monday = 1, and so on. 
wDay 
Specifies the current day of the month. 
wHour 
Specifies the current hour. 
wMinute 
Specifies the current minute. 
wSecond 
Specifies the current second. 
wMilliseconds 
Specifies the current millisecond. 
Remarks
It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should 

Convert the SYSTEMTIME structure to a FILETIME structure. 
Copy the resulting FILETIME structure to a LARGE_INTEGER structure. 
Use normal 64-bit arithmetic on the LARGE_INTEGER value. 
QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winbase.h.

See Also
Time Overview, Time Structures, FILETIME, GetSystemTime, LARGE_INTEGER, SetSystemTime 

 

热点排行