1 #define TIME_FIXUP_CONSTANT1 (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
2 #define TIME_FIXUP_CONSTANT2 (TIME_FIXUP_CONSTANT1)
4 /****************************************************************************
5 interpret an 8 byte "filetime" structure to a time_t
6 It's originally in "100ns units since jan 1st 1601"
8 It appears to be kludge-GMT (at least for file listings). This means
9 its the GMT you get by taking a localtime and adding the
10 serverzone. This is NOT the same as GMT in some cases. This routine
11 converts this to real GMT.
12 ****************************************************************************/
13 time_t interpret_long_date(char *p)
21 if (thigh == 0) return(0);
23 d = ((double)thigh)*4.0*(double)(1<<30);
24 d += (tlow&0xFFF00000);
27 /* now adjust by 369 years to make the secs since 1970 */
28 d -= TIME_FIXUP_CONSTANT1;
30 if (!(TIME_T_MIN <= d && d <= TIME_T_MAX))
33 ret = (time_t)(d+0.5);
35 /* this takes us from kludge-GMT to real GMT */
37 ret += LocTimeDiff(ret);
43 /****************************************************************************
44 put a 8 byte filetime from a time_t
45 This takes real GMT as input and converts to kludge-GMT
46 ****************************************************************************/
47 void put_long_date(char *p,time_t t)
53 SIVAL(p,0,0); SIVAL(p,4,0);
57 /* this converts GMT to kludge-GMT */
58 t -= LocTimeDiff(t) - serverzone;
62 d += TIME_FIXUP_CONSTANT2;
66 thigh = (uint32)(d * (1.0/(4.0*(double)(1<<30))));
67 tlow = (uint32)(d - ((double)thigh)*4.0*(double)(1<<30));
73 int main(int argc, char *argv[])