ReactOS 0.4.16-dev-250-g3ecd236
time.h
Go to the documentation of this file.
1#define DIFFTIME 0x19db1ded53e8000ULL
2#define DIFFDAYS (3 * DAYSPER100YEARS + 17 * DAYSPER4YEARS + 1 * DAYSPERYEAR)
3
4#define DAYSPERYEAR 365
5#define DAYSPER4YEARS (4*DAYSPERYEAR+1)
6#define DAYSPER100YEARS (25*DAYSPER4YEARS-1)
7#define DAYSPER400YEARS (4*DAYSPER100YEARS+1)
8#define SECONDSPERDAY (24*60*60)
9#define SECONDSPERHOUR (60*60)
10#define LEAPDAY 59
11
12static __inline
13__time64_t
14FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm)
15{
16 ULARGE_INTEGER ULargeInt;
17 __time64_t time;
18
19 ULargeInt.LowPart = FileTime->dwLowDateTime;
20 ULargeInt.HighPart = FileTime->dwHighDateTime;
21 ULargeInt.QuadPart -= DIFFTIME;
22
23 time = ULargeInt.QuadPart / 10000000;
24 if (millitm)
25 *millitm = (USHORT)((ULargeInt.QuadPart % 10000000) / 10000);
26
27 return time;
28}
29
30static __inline
31long leapyears_passed(long days)
32{
33 long quadcenturies, centuries, quadyears;
34 quadcenturies = days / DAYSPER400YEARS;
35 days -= quadcenturies;
36 centuries = days / DAYSPER100YEARS;
37 days += centuries;
38 quadyears = days / DAYSPER4YEARS;
39 return quadyears - centuries + quadcenturies;
40}
41
42static __inline
43long leapdays_passed(long days)
44{
45 return leapyears_passed(days + DAYSPERYEAR - LEAPDAY + 1);
46}
47
48static __inline
49long years_passed(long days)
50{
51 return (days - leapdays_passed(days)) / 365;
52}
53
54extern long dst_begin;
55extern long dst_end;
__u16 time
Definition: mkdosfs.c:8
unsigned short USHORT
Definition: pedump.c:61
static __inline long leapdays_passed(long days)
Definition: time.h:43
static __inline long years_passed(long days)
Definition: time.h:49
#define DAYSPER100YEARS
Definition: time.h:6
#define DAYSPERYEAR
Definition: time.h:4
#define LEAPDAY
Definition: time.h:10
static __inline __time64_t FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm)
Definition: time.h:14
long dst_begin
Definition: timezone.c:16
#define DIFFTIME
Definition: time.h:1
#define DAYSPER400YEARS
Definition: time.h:7
long dst_end
Definition: timezone.c:17
static __inline long leapyears_passed(long days)
Definition: time.h:31
#define DAYSPER4YEARS
Definition: time.h:5
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
$ULONG LowPart
Definition: ntbasedef.h:577
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:578