Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6fd2ae13
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6fd2ae13
编写于
8月 07, 2023
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: taosMktime on windows platform
上级
7ae36630
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
40 deletion
+53
-40
include/os/osTime.h
include/os/osTime.h
+2
-0
source/common/src/ttime.c
source/common/src/ttime.c
+0
-40
source/os/src/osTime.c
source/os/src/osTime.c
+51
-0
未找到文件。
include/os/osTime.h
浏览文件 @
6fd2ae13
...
@@ -95,6 +95,8 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf);
...
@@ -95,6 +95,8 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf);
struct
tm
*
taosLocalTimeNolock
(
struct
tm
*
result
,
const
time_t
*
timep
,
int
dst
);
struct
tm
*
taosLocalTimeNolock
(
struct
tm
*
result
,
const
time_t
*
timep
,
int
dst
);
time_t
taosTime
(
time_t
*
t
);
time_t
taosTime
(
time_t
*
t
);
time_t
taosMktime
(
struct
tm
*
timep
);
time_t
taosMktime
(
struct
tm
*
timep
);
int64_t
user_mktime64
(
const
uint32_t
year
,
const
uint32_t
mon
,
const
uint32_t
day
,
const
uint32_t
hour
,
const
uint32_t
min
,
const
uint32_t
sec
,
int64_t
time_zone
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/common/src/ttime.c
浏览文件 @
6fd2ae13
...
@@ -25,46 +25,6 @@
...
@@ -25,46 +25,6 @@
#include "tlog.h"
#include "tlog.h"
/*
* mktime64 - Converts date to seconds.
* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
* Assumes input in normal date format, i.e. 1980-12-31 23:59:59
* => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
*
* [For the Julian calendar (which was used in Russia before 1917,
* Britain & colonies before 1752, anywhere else before 1582,
* and is still in use by some communities) leave out the
* -year/100+year/400 terms, and add 10.]
*
* This algorithm was first published by Gauss (I think).
*
* A leap second can be indicated by calling this function with sec as
* 60 (allowable under ISO 8601). The leap second is treated the same
* as the following second since they don't exist in UNIX time.
*
* An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
* tomorrow - (allowable under ISO 8601) is supported.
*/
static
int64_t
user_mktime64
(
const
uint32_t
year0
,
const
uint32_t
mon0
,
const
uint32_t
day
,
const
uint32_t
hour
,
const
uint32_t
min
,
const
uint32_t
sec
,
int64_t
time_zone
)
{
uint32_t
mon
=
mon0
,
year
=
year0
;
/* 1..12 -> 11,12,1..10 */
if
(
0
>=
(
int32_t
)(
mon
-=
2
))
{
mon
+=
12
;
/* Puts Feb last since it has leap day */
year
-=
1
;
}
// int64_t res = (((((int64_t) (year/4 - year/100 + year/400 + 367*mon/12 + day) +
// year*365 - 719499)*24 + hour)*60 + min)*60 + sec);
int64_t
res
;
res
=
367
*
((
int64_t
)
mon
)
/
12
;
res
+=
year
/
4
-
year
/
100
+
year
/
400
+
day
+
((
int64_t
)
year
)
*
365
-
719499
;
res
=
res
*
24
;
res
=
((
res
+
hour
)
*
60
+
min
)
*
60
+
sec
;
return
(
res
+
time_zone
);
}
// ==== mktime() kernel code =================//
// ==== mktime() kernel code =================//
static
int64_t
m_deltaUtc
=
0
;
static
int64_t
m_deltaUtc
=
0
;
...
...
source/os/src/osTime.c
浏览文件 @
6fd2ae13
...
@@ -367,8 +367,50 @@ int32_t taosGetTimeOfDay(struct timeval *tv) {
...
@@ -367,8 +367,50 @@ int32_t taosGetTimeOfDay(struct timeval *tv) {
time_t
taosTime
(
time_t
*
t
)
{
return
time
(
t
);
}
time_t
taosTime
(
time_t
*
t
)
{
return
time
(
t
);
}
/*
* mktime64 - Converts date to seconds.
* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
* Assumes input in normal date format, i.e. 1980-12-31 23:59:59
* => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
*
* [For the Julian calendar (which was used in Russia before 1917,
* Britain & colonies before 1752, anywhere else before 1582,
* and is still in use by some communities) leave out the
* -year/100+year/400 terms, and add 10.]
*
* This algorithm was first published by Gauss (I think).
*
* A leap second can be indicated by calling this function with sec as
* 60 (allowable under ISO 8601). The leap second is treated the same
* as the following second since they don't exist in UNIX time.
*
* An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
* tomorrow - (allowable under ISO 8601) is supported.
*/
int64_t
user_mktime64
(
const
uint32_t
year
,
const
uint32_t
mon
,
const
uint32_t
day
,
const
uint32_t
hour
,
const
uint32_t
min
,
const
uint32_t
sec
,
int64_t
time_zone
)
{
uint32_t
_mon
=
mon
,
_year
=
year
;
/* 1..12 -> 11,12,1..10 */
if
(
0
>=
(
int32_t
)(
_mon
-=
2
))
{
_mon
+=
12
;
/* Puts Feb last since it has leap day */
_year
-=
1
;
}
// int64_t _res = (((((int64_t) (_year/4 - _year/100 + _year/400 + 367*_mon/12 + day) +
// _year*365 - 719499)*24 + hour)*60 + min)*60 + sec);
int64_t
_res
;
_res
=
367
*
((
int64_t
)
_mon
)
/
12
;
_res
+=
_year
/
4
-
_year
/
100
+
_year
/
400
+
day
+
((
int64_t
)
_year
)
*
365
-
719499
;
_res
=
_res
*
24
;
_res
=
((
_res
+
hour
)
*
60
+
min
)
*
60
+
sec
;
return
(
_res
+
time_zone
);
}
time_t
taosMktime
(
struct
tm
*
timep
)
{
time_t
taosMktime
(
struct
tm
*
timep
)
{
#ifdef WINDOWS
#ifdef WINDOWS
#if 0
struct tm tm1 = {0};
struct tm tm1 = {0};
LARGE_INTEGER t;
LARGE_INTEGER t;
FILETIME f;
FILETIME f;
...
@@ -405,6 +447,15 @@ time_t taosMktime(struct tm *timep) {
...
@@ -405,6 +447,15 @@ time_t taosMktime(struct tm *timep) {
t.QuadPart -= offset.QuadPart;
t.QuadPart -= offset.QuadPart;
return (time_t)(t.QuadPart / 10000000);
return (time_t)(t.QuadPart / 10000000);
#else
#ifdef _MSC_VER
#if _MSC_VER >= 1900
int64_t
tz
=
_timezone
;
#endif
#endif
return
user_mktime64
(
timep
->
tm_year
+
1900
,
timep
->
tm_mon
+
1
,
timep
->
tm_mday
,
timep
->
tm_hour
,
timep
->
tm_min
,
timep
->
tm_sec
,
tz
);
#endif
#else
#else
return
mktime
(
timep
);
return
mktime
(
timep
);
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录