Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3ce28c06
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3ce28c06
编写于
8月 02, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5505]<fix>: return error if there're additional illegal characters
after timezeone str
上级
83b5c2a6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
5 deletion
+50
-5
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+14
-5
src/query/tests/unitTest.cpp
src/query/tests/unitTest.cpp
+36
-0
未找到文件。
src/os/src/detail/osTime.c
浏览文件 @
3ce28c06
...
...
@@ -72,12 +72,12 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
// ==== mktime() kernel code =================//
static
int64_t
m_deltaUtc
=
0
;
void
deltaToUtcInitOnce
()
{
void
deltaToUtcInitOnce
()
{
struct
tm
tm
=
{
0
};
(
void
)
strptime
(
"1970-01-01 00:00:00"
,
(
const
char
*
)(
"%Y-%m-%d %H:%M:%S"
),
&
tm
);
m_deltaUtc
=
(
int64_t
)
mktime
(
&
tm
);
//printf("====delta:%lld\n\n", seconds);
//printf("====delta:%lld\n\n", seconds);
return
;
}
...
...
@@ -90,7 +90,7 @@ static char* forwardToTimeStringEnd(char* str);
static
int32_t
(
*
parseLocaltimeFp
[])
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
=
{
parseLocaltime
,
parseLocaltimeWithDst
};
};
int32_t
taosGetTimestampSec
()
{
return
(
int32_t
)
time
(
NULL
);
}
...
...
@@ -194,6 +194,13 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
i
+=
2
;
}
//return error if there're illegal charaters after min(2 Digits)
char
*
minStr
=
&
str
[
i
];
if
(
minStr
[
1
]
!=
'\0'
&&
minStr
[
2
]
!=
'\0'
)
{
return
-
1
;
}
int64_t
minute
=
strnatoi
(
&
str
[
i
],
2
);
if
(
minute
>
59
)
{
return
-
1
;
...
...
@@ -252,7 +259,7 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
int64_t
fraction
=
0
;
str
=
forwardToTimeStringEnd
(
timestr
);
if
(
str
[
0
]
==
'Z'
||
str
[
0
]
==
'z
'
)
{
if
(
(
str
[
0
]
==
'Z'
||
str
[
0
]
==
'z'
)
&&
str
[
1
]
==
'\0
'
)
{
/* utc time, no millisecond, return directly*/
*
time
=
seconds
*
factor
;
}
else
if
(
str
[
0
]
==
'.'
)
{
...
...
@@ -266,6 +273,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
char
seg
=
str
[
0
];
if
(
seg
!=
'Z'
&&
seg
!=
'z'
&&
seg
!=
'+'
&&
seg
!=
'-'
)
{
return
-
1
;
}
else
if
((
seg
==
'Z'
||
seg
==
'z'
)
&&
str
[
1
]
!=
'\0'
)
{
return
-
1
;
}
else
if
(
seg
==
'+'
||
seg
==
'-'
)
{
// parse the timezone
if
(
parseTimezone
(
str
,
&
tzOffset
)
==
-
1
)
{
...
...
src/query/tests/unitTest.cpp
浏览文件 @
3ce28c06
...
...
@@ -462,6 +462,42 @@ TEST(testCase, parse_time) {
char
t23
[]
=
"2017-12-31T9:0:0.1+13:1"
;
EXPECT_EQ
(
taosParseTime
(
t23
,
&
time
,
strlen
(
t23
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
char
t24
[]
=
"2017-12-31T9:0:0.1+13:001"
;
EXPECT_EQ
(
taosParseTime
(
t24
,
&
time
,
strlen
(
t24
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t25
[]
=
"2017-12-31T9:0:0.1+13:00abc"
;
EXPECT_EQ
(
taosParseTime
(
t25
,
&
time
,
strlen
(
t25
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t26
[]
=
"2017-12-31T9:0:0.1+13001"
;
EXPECT_EQ
(
taosParseTime
(
t26
,
&
time
,
strlen
(
t26
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t27
[]
=
"2017-12-31T9:0:0.1+1300abc"
;
EXPECT_EQ
(
taosParseTime
(
t27
,
&
time
,
strlen
(
t27
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t28
[]
=
"2017-12-31T9:0:0Z+12:00"
;
EXPECT_EQ
(
taosParseTime
(
t28
,
&
time
,
strlen
(
t28
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t29
[]
=
"2017-12-31T9:0:0.123Z+12:00"
;
EXPECT_EQ
(
taosParseTime
(
t29
,
&
time
,
strlen
(
t29
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t65
[]
=
"2017-12-31 9:0:0.1+13:001"
;
EXPECT_EQ
(
taosParseTime
(
t65
,
&
time
,
strlen
(
t65
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t66
[]
=
"2017-12-31 9:0:0.1+13:00abc"
;
EXPECT_EQ
(
taosParseTime
(
t66
,
&
time
,
strlen
(
t66
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t67
[]
=
"2017-12-31 9:0:0.1+13001"
;
EXPECT_EQ
(
taosParseTime
(
t67
,
&
time
,
strlen
(
t67
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t68
[]
=
"2017-12-31 9:0:0.1+1300abc"
;
EXPECT_EQ
(
taosParseTime
(
t68
,
&
time
,
strlen
(
t68
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t69
[]
=
"2017-12-31 9:0:0Z+12:00"
;
EXPECT_EQ
(
taosParseTime
(
t69
,
&
time
,
strlen
(
t69
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t70
[]
=
"2017-12-31 9:0:0.123Z+12:00"
;
EXPECT_EQ
(
taosParseTime
(
t70
,
&
time
,
strlen
(
t70
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
}
TEST
(
testCase
,
tvariant_convert
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录