forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTime.cpp
More file actions
58 lines (45 loc) · 1.43 KB
/
Time.cpp
File metadata and controls
58 lines (45 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "os/c-api/il2cpp-config-platforms.h"
#include "os/Time.h"
#include <stdint.h>
#include <time.h>
extern "C"
{
#if !RUNTIME_TINY
uint32_t UnityPalGetTicksMillisecondsMonotonic()
{
return il2cpp::os::Time::GetTicksMillisecondsMonotonic();
}
int64_t UnityPalGetTicks100NanosecondsDateTime()
{
return il2cpp::os::Time::GetTicks100NanosecondsDateTime();
}
#endif
int64_t STDCALL UnityPalGetTicks100NanosecondsMonotonic()
{
return il2cpp::os::Time::GetTicks100NanosecondsMonotonic();
}
int64_t STDCALL UnityPalGetSystemTimeAsFileTime()
{
return il2cpp::os::Time::GetSystemTimeAsFileTime();
}
#if IL2CPP_TINY
int32_t STDCALL UnityPalGetUtcOffsetHours(int64_t secondsSinceEpoch)
{
struct tm* utcTime = gmtime((time_t*)&secondsSinceEpoch);
time_t utc = mktime(utcTime);
struct tm* localTime = localtime((time_t*)&secondsSinceEpoch);
time_t local = mktime(localTime);
time_t offsetSeconds = local - utc;
int daylightSavingsOffset = 0;
if (localTime->tm_isdst)
daylightSavingsOffset = 1;
return (int32_t)offsetSeconds / 3600 + daylightSavingsOffset;
}
bool STDCALL UnityPalIsDaylightSavingsTime(int64_t secondsSinceEpoch)
{
struct tm* tt = localtime((time_t*)&secondsSinceEpoch);
int32_t daylightSavingsOffset = 0;
return tt->tm_isdst > 0;
}
#endif
}