summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/XTimeUtils.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/utils/XTimeUtils.h')
-rw-r--r--xbmc/utils/XTimeUtils.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/xbmc/utils/XTimeUtils.h b/xbmc/utils/XTimeUtils.h
new file mode 100644
index 0000000..91cda40
--- /dev/null
+++ b/xbmc/utils/XTimeUtils.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2005-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include <chrono>
+#include <string>
+#include <thread>
+
+#if !defined(TARGET_WINDOWS)
+#include "PlatformDefs.h"
+#else
+// This is needed, a forward declaration of FILETIME
+// breaks everything
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <Windows.h>
+#endif
+
+namespace KODI
+{
+namespace TIME
+{
+struct SystemTime
+{
+ unsigned short year;
+ unsigned short month;
+ unsigned short dayOfWeek;
+ unsigned short day;
+ unsigned short hour;
+ unsigned short minute;
+ unsigned short second;
+ unsigned short milliseconds;
+};
+
+struct TimeZoneInformation
+{
+ long bias;
+ std::string standardName;
+ SystemTime standardDate;
+ long standardBias;
+ std::string daylightName;
+ SystemTime daylightDate;
+ long daylightBias;
+};
+
+constexpr int KODI_TIME_ZONE_ID_INVALID{-1};
+constexpr int KODI_TIME_ZONE_ID_UNKNOWN{0};
+constexpr int KODI_TIME_ZONE_ID_STANDARD{1};
+constexpr int KODI_TIME_ZONE_ID_DAYLIGHT{2};
+
+struct FileTime
+{
+ unsigned int lowDateTime;
+ unsigned int highDateTime;
+};
+
+void GetLocalTime(SystemTime* systemTime);
+uint32_t GetTimeZoneInformation(TimeZoneInformation* timeZoneInformation);
+
+template<typename Rep, typename Period>
+void Sleep(std::chrono::duration<Rep, Period> duration)
+{
+ if (duration == std::chrono::duration<Rep, Period>::zero())
+ {
+ std::this_thread::yield();
+ return;
+ }
+
+ std::this_thread::sleep_for(duration);
+}
+
+int FileTimeToLocalFileTime(const FileTime* fileTime, FileTime* localFileTime);
+int SystemTimeToFileTime(const SystemTime* systemTime, FileTime* fileTime);
+long CompareFileTime(const FileTime* fileTime1, const FileTime* fileTime2);
+int FileTimeToSystemTime(const FileTime* fileTime, SystemTime* systemTime);
+int LocalFileTimeToFileTime(const FileTime* LocalFileTime, FileTime* fileTime);
+
+int FileTimeToTimeT(const FileTime* localFileTime, time_t* pTimeT);
+int TimeTToFileTime(time_t timeT, FileTime* localFileTime);
+} // namespace TIME
+} // namespace KODI