summaryrefslogtreecommitdiff
path: root/include/m_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/m_utils.h')
-rw-r--r--include/m_utils.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/include/m_utils.h b/include/m_utils.h
index 9ba9485c8c..3ce8b68de3 100644
--- a/include/m_utils.h
+++ b/include/m_utils.h
@@ -3,7 +3,7 @@
Miranda NG: the free IM client for Microsoft* Windows*
-Copyright (C) 2012-24 Miranda NG team (https://miranda-ng.org)
+Copyright (C) 2012-25 Miranda NG team (https://miranda-ng.org)
Copyright (c) 2000-12 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
@@ -435,6 +435,17 @@ EXTERN_C MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen);
EXTERN_C MIR_CORE_DLL(bool) Utils_IsRtl(const wchar_t *pszwText);
/////////////////////////////////////////////////////////////////////////////////////////
+// Converts a timestamp in the ISO format to time_t
+
+EXTERN_C MIR_CORE_DLL(time_t) Utils_IsoToUnixTime(const char *pszIsoTimestamp);
+
+#ifdef _XSTRING_
+__forceinline time_t Utils_IsoToUnixTime(const std::string &str) {
+ return Utils_IsoToUnixTime(str.c_str());
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////
// UUID generator
MIR_CORE_DLL(CMStringA) Utils_GenerateUUID();
@@ -517,6 +528,20 @@ struct MIR_APP_EXPORT MAsyncObject : public MNonCopyable
MIR_APP_DLL(void) Utils_InvokeAsync(MAsyncObject *pObj);
/////////////////////////////////////////////////////////////////////////////////////////
+
+class MEventHandle
+{
+ HANDLE _hEvent;
+public:
+ __inline explicit MEventHandle() { _hEvent = CreateEvent(NULL, 0, 0, NULL); }
+ __inline explicit MEventHandle(HANDLE hEvent) : _hEvent(hEvent) {}
+ __inline ~MEventHandle() { CloseHandle(_hEvent); }
+ __inline void Set() { SetEvent(_hEvent); }
+ __inline void Wait(uint32_t dwMilliseconds = INFINITE) { WaitForSingleObject(_hEvent, dwMilliseconds); }
+ __inline operator HANDLE() { return _hEvent; }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
// compatibility functions
#ifndef _WINDOWS