hydrogen 1.2.3
Timehelper.cpp
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#ifdef WIN32
25
26#include <time.h>
27#include "Timehelper.h"
28
29
30int gettimeofday(struct timeval *tv, struct timezone *tz)
31{
32 FILETIME ft;
33 unsigned __int64 tmpres = 0;
34 static int tzflag;
35
36 if (NULL != tv)
37 {
38 GetSystemTimeAsFileTime(&ft);
39
40 tmpres |= ft.dwHighDateTime;
41 tmpres <<= 32;
42 tmpres |= ft.dwLowDateTime;
43
44 /*converting file time to unix epoch*/
45 tmpres /= 10; /*convert into microseconds*/
47 tv->tv_sec = (long)(tmpres / 1000000UL);
48 tv->tv_usec = (long)(tmpres % 1000000UL);
49 }
50
51 if (NULL != tz)
52 {
53 if (!tzflag)
54 {
55 _tzset();
56 tzflag++;
57 }
58 tz->tz_minuteswest = _timezone / 60;
59 tz->tz_dsttime = _daylight;
60 }
61
62 return 0;
63}
64
65#endif
int gettimeofday(struct timeval *tv, struct timezone *tz)
#define DELTA_EPOCH_IN_MICROSECS
Definition Timehelper.h:35
int tz_dsttime
Definition Timehelper.h:63
int tz_minuteswest
Definition Timehelper.h:62