1 /*
2  *  Copyright (C) 2005-2018 Team Kodi
3  *  This file is part of Kodi - https://kodi.tv
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  *  See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <string>
12 
13 #if !defined(TARGET_WINDOWS)
14 #include "PlatformDefs.h"
15 #else
16 // This is needed, a forward declaration of FILETIME
17 // breaks everything
18 #ifndef WIN32_LEAN_AND_MEAN
19 #define WIN32_LEAN_AND_MEAN
20 #endif
21 #include <Windows.h>
22 #endif
23 
24 namespace KODI
25 {
26 namespace TIME
27 {
28 struct SystemTime
29 {
30   unsigned short year;
31   unsigned short month;
32   unsigned short dayOfWeek;
33   unsigned short day;
34   unsigned short hour;
35   unsigned short minute;
36   unsigned short second;
37   unsigned short milliseconds;
38 };
39 
40 struct TimeZoneInformation
41 {
42   long bias;
43   std::string standardName;
44   SystemTime standardDate;
45   long standardBias;
46   std::string daylightName;
47   SystemTime daylightDate;
48   long daylightBias;
49 };
50 
51 constexpr int KODI_TIME_ZONE_ID_INVALID{-1};
52 constexpr int KODI_TIME_ZONE_ID_UNKNOWN{0};
53 constexpr int KODI_TIME_ZONE_ID_STANDARD{1};
54 constexpr int KODI_TIME_ZONE_ID_DAYLIGHT{2};
55 
56 struct FileTime
57 {
58   unsigned int lowDateTime;
59   unsigned int highDateTime;
60 };
61 
62 void GetLocalTime(SystemTime* systemTime);
63 uint32_t GetTimeZoneInformation(TimeZoneInformation* timeZoneInformation);
64 
65 void Sleep(uint32_t milliSeconds);
66 
67 int FileTimeToLocalFileTime(const FileTime* fileTime, FileTime* localFileTime);
68 int SystemTimeToFileTime(const SystemTime* systemTime, FileTime* fileTime);
69 long CompareFileTime(const FileTime* fileTime1, const FileTime* fileTime2);
70 int FileTimeToSystemTime(const FileTime* fileTime, SystemTime* systemTime);
71 int LocalFileTimeToFileTime(const FileTime* LocalFileTime, FileTime* fileTime);
72 
73 int FileTimeToTimeT(const FileTime* localFileTime, time_t* pTimeT);
74 int TimeTToFileTime(time_t timeT, FileTime* localFileTime);
75 } // namespace TIME
76 } // namespace KODI
77