Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1a5adfc5
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1a5adfc5
编写于
1月 28, 2023
作者:
X
xinsheng Ren
提交者:
GitHub
1月 28, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:getTimeOfDay on windows (#19680)
上级
e8dfa667
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
32 deletion
+15
-32
source/os/src/osTime.c
source/os/src/osTime.c
+15
-32
未找到文件。
source/os/src/osTime.c
浏览文件 @
1a5adfc5
...
...
@@ -33,6 +33,11 @@
#include <time.h>
//#define TM_YEAR_BASE 1970 //origin
#define TM_YEAR_BASE 1900 // slguan
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
// until 00:00:00 January 1, 1970
static
const
uint64_t
TIMEEPOCH
=
((
uint64_t
)
116444736000000000ULL
);
/*
* We do not implement alternate representations. However, we always
* check whether a given modifier is allowed for a certain conversion.
...
...
@@ -341,15 +346,17 @@ char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm) {
int32_t
taosGetTimeOfDay
(
struct
timeval
*
tv
)
{
#ifdef WINDOWS
time_t
t
;
t
=
taosGetTimestampSec
();
SYSTEMTIME
st
;
GetLocalTime
(
&
st
);
LARGE_INTEGER
t
;
FILETIME
f
;
tv
->
tv_sec
=
(
long
)
t
;
tv
->
tv_usec
=
st
.
wMilliseconds
*
1000
;
GetSystemTimeAsFileTime
(
&
f
);
t
.
QuadPart
=
f
.
dwHighDateTime
;
t
.
QuadPart
<<=
32
;
t
.
QuadPart
|=
f
.
dwLowDateTime
;
return
0
;
t
.
QuadPart
-=
TIMEEPOCH
;
tv
->
tv_sec
=
t
.
QuadPart
/
10000000
;
tv
->
tv_usec
=
(
t
.
QuadPart
%
10000000
)
/
10
;
#else
return
gettimeofday
(
tv
,
NULL
);
#endif
...
...
@@ -550,37 +557,13 @@ int32_t taosClockGetTime(int clock_id, struct timespec *pTS) {
#ifdef WINDOWS
LARGE_INTEGER
t
;
FILETIME
f
;
static
FILETIME
ff
;
static
SYSTEMTIME
ss
;
static
LARGE_INTEGER
offset
;
static
int8_t
offsetInit
=
0
;
static
volatile
bool
offsetInitFinished
=
false
;
int8_t
old
=
atomic_val_compare_exchange_8
(
&
offsetInit
,
0
,
1
);
if
(
0
==
old
)
{
ss
.
wYear
=
1970
;
ss
.
wMonth
=
1
;
ss
.
wDay
=
1
;
ss
.
wHour
=
0
;
ss
.
wMinute
=
0
;
ss
.
wSecond
=
0
;
ss
.
wMilliseconds
=
0
;
SystemTimeToFileTime
(
&
ss
,
&
ff
);
offset
.
QuadPart
=
ff
.
dwHighDateTime
;
offset
.
QuadPart
<<=
32
;
offset
.
QuadPart
|=
ff
.
dwLowDateTime
;
offsetInitFinished
=
true
;
}
else
{
while
(
!
offsetInitFinished
)
;
// Ensure initialization is completed.
}
GetSystemTimeAsFileTime
(
&
f
);
t
.
QuadPart
=
f
.
dwHighDateTime
;
t
.
QuadPart
<<=
32
;
t
.
QuadPart
|=
f
.
dwLowDateTime
;
t
.
QuadPart
-=
offset
.
QuadPart
;
t
.
QuadPart
-=
TIMEEPOCH
;
pTS
->
tv_sec
=
t
.
QuadPart
/
10000000
;
pTS
->
tv_nsec
=
(
t
.
QuadPart
%
10000000
)
*
100
;
return
(
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录