xbmc
XTimeUtils.h
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 <chrono>
12 #include <string>
13 #include <thread>
14 
15 #if !defined(TARGET_WINDOWS)
16 #include "PlatformDefs.h"
17 #else
18 // This is needed, a forward declaration of FILETIME
19 // breaks everything
20 #ifndef WIN32_LEAN_AND_MEAN
21 #define WIN32_LEAN_AND_MEAN
22 #endif
23 #include <Windows.h>
24 #endif
25 
26 namespace KODI
27 {
28 namespace TIME
29 {
30 struct SystemTime
31 {
32  unsigned short year;
33  unsigned short month;
34  unsigned short dayOfWeek;
35  unsigned short day;
36  unsigned short hour;
37  unsigned short minute;
38  unsigned short second;
39  unsigned short milliseconds;
40 };
41 
43 {
44  long bias;
45  std::string standardName;
46  SystemTime standardDate;
47  long standardBias;
48  std::string daylightName;
49  SystemTime daylightDate;
50  long daylightBias;
51 };
52 
53 constexpr int KODI_TIME_ZONE_ID_INVALID{-1};
54 constexpr int KODI_TIME_ZONE_ID_UNKNOWN{0};
55 constexpr int KODI_TIME_ZONE_ID_STANDARD{1};
56 constexpr int KODI_TIME_ZONE_ID_DAYLIGHT{2};
57 
58 struct FileTime
59 {
60  unsigned int lowDateTime;
61  unsigned int highDateTime;
62 };
63 
64 void GetLocalTime(SystemTime* systemTime);
65 uint32_t GetTimeZoneInformation(TimeZoneInformation* timeZoneInformation);
66 
67 template<typename Rep, typename Period>
68 void Sleep(std::chrono::duration<Rep, Period> duration)
69 {
70  if (duration == std::chrono::duration<Rep, Period>::zero())
71  {
72  std::this_thread::yield();
73  return;
74  }
75 
76  std::this_thread::sleep_for(duration);
77 }
78 
79 int FileTimeToLocalFileTime(const FileTime* fileTime, FileTime* localFileTime);
80 int SystemTimeToFileTime(const SystemTime* systemTime, FileTime* fileTime);
81 long CompareFileTime(const FileTime* fileTime1, const FileTime* fileTime2);
82 int FileTimeToSystemTime(const FileTime* fileTime, SystemTime* systemTime);
83 int LocalFileTimeToFileTime(const FileTime* LocalFileTime, FileTime* fileTime);
84 
85 int FileTimeToTimeT(const FileTime* localFileTime, time_t* pTimeT);
86 int TimeTToFileTime(time_t timeT, FileTime* localFileTime);
87 } // namespace TIME
88 } // namespace KODI
Definition: XTimeUtils.h:30
Controller configuration window.
Definition: AudioDecoder.h:18
Definition: XTimeUtils.h:42
Definition: XTimeUtils.h:58