dvitomp fix from Akira
[mplib] / src / texk / kpathsea / time.c
1 /* Utility and Unix shadow routines for XEmacs on Windows NT.
2    Copyright (C) 1994, 1995 Free Software Foundation, Inc.
3
4 This file is part of XEmacs.
5
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING.  If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20
21
22    Geoff Voelker (voelker@cs.washington.edu) 7-29-94 */
23
24 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
25 /* Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
26 /* Adapted to fpTeX 0.4 by Fabrice Popineau <Fabrice.Popineau@supelec.fr> */
27
28 #ifdef __MINGW32__
29
30 #include <kpathsea/config.h>
31 #include <kpathsea/c-proto.h>
32 #include <kpathsea/win32lib.h>
33 #include <kpathsea/lib.h>
34
35 FILETIME utc_base_ft;
36 static long double utc_base;
37 static int init = 0;
38
39 time_t
40 convert_time (FILETIME ft)
41 {
42   long double ret;
43
44   if (!init)
45     {
46       /* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
47       SYSTEMTIME st;
48
49       st.wYear = 1970;
50       st.wMonth = 1;
51       st.wDay = 1;
52       st.wHour = 0;
53       st.wMinute = 0;
54       st.wSecond = 0;
55       st.wMilliseconds = 0;
56
57       SystemTimeToFileTime (&st, &utc_base_ft);
58       utc_base = (long double) utc_base_ft.dwHighDateTime
59         * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime;
60       init = 1;
61     }
62
63   if (CompareFileTime (&ft, &utc_base_ft) < 0)
64     return 0;
65
66   ret = (long double) ft.dwHighDateTime * 4096 * 1024 * 1024 + ft.dwLowDateTime;
67   ret -= utc_base;
68   return (time_t) (ret * 1e-7);
69 }
70
71 #endif