質問編集履歴
1
解決した時のコードを追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -65,4 +65,64 @@
|
|
65
65
|
9時間と聞いてピンとくるのは「日本標準時 (JST) は協定世界時より9時間早い」という事実です。
|
66
66
|
JavaのcurrentTimeMillisは日本時間を返しているということなのでしょうか?
|
67
67
|
|
68
|
-
よろしくお願いいたします。
|
68
|
+
よろしくお願いいたします。
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
追伸:
|
74
|
+
解決しましたが解決したときのコードがきれいに貼れなかったのでここに貼っておきます。
|
75
|
+
```C++
|
76
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
77
|
+
#define WIN32_LEAN_AND_MEAN
|
78
|
+
#endif
|
79
|
+
#ifndef _WIN32_WINNT
|
80
|
+
#define _WIN32_WINNT 0x0500
|
81
|
+
#endif
|
82
|
+
#ifndef OEMRESOURCE
|
83
|
+
#define OEMRESOURCE
|
84
|
+
#endif
|
85
|
+
#ifndef STRICT
|
86
|
+
#define STRICT
|
87
|
+
#endif
|
88
|
+
#include <windows.h>
|
89
|
+
#include <ctime>
|
90
|
+
#include <iostream>
|
91
|
+
|
92
|
+
time_t make_time_t(const SYSTEMTIME & st)
|
93
|
+
{
|
94
|
+
tm time_data;
|
95
|
+
ZeroMemory(&time_data, sizeof(time_data));
|
96
|
+
time_data.tm_year = st.wYear - 1900;
|
97
|
+
time_data.tm_mon = st.wMonth - 1;
|
98
|
+
time_data.tm_mday = st.wDay;
|
99
|
+
time_data.tm_hour = st.wHour;
|
100
|
+
time_data.tm_min = st.wMinute;
|
101
|
+
time_data.tm_sec = st.wSecond;
|
102
|
+
time_data.tm_isdst = 0;
|
103
|
+
return mktime(&time_data);
|
104
|
+
}
|
105
|
+
|
106
|
+
unsigned long long time_to_ms(const SYSTEMTIME & systime)
|
107
|
+
{
|
108
|
+
FILETIME file_time;
|
109
|
+
SystemTimeToFileTime(&systime, &file_time);
|
110
|
+
FILETIME local_ft;
|
111
|
+
FileTimeToLocalFileTime(&file_time, &local_ft);
|
112
|
+
SYSTEMTIME local_time;
|
113
|
+
FileTimeToSystemTime(&local_ft, &local_time);
|
114
|
+
time_t seconds = make_time_t(local_time);
|
115
|
+
return seconds * 1000 + systime.wMilliseconds;
|
116
|
+
}
|
117
|
+
|
118
|
+
int main()
|
119
|
+
{
|
120
|
+
SYSTEMTIME time;
|
121
|
+
GetSystemTime(&time);
|
122
|
+
std::cout << time.wYear << "year " << time.wMonth << "month " << time.wDay << "day " << time.wHour << "h " << time.wMinute << "min " << time.wSecond << "sec " << time.wMilliseconds << "ms" << std::endl;
|
123
|
+
unsigned long long count = time_to_ms(time);
|
124
|
+
std::cout << count << std::endl;
|
125
|
+
|
126
|
+
return 0;
|
127
|
+
}
|
128
|
+
```
|