Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
314950e0
Commit
314950e0
authored
Oct 08, 2020
by
Claes
Committed by
Esteban Blanc
Dec 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time_AsciiToA() handles different formats
parent
20dfb924
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
src/lib/co/src/co_time.c
src/lib/co/src/co_time.c
+26
-10
No files found.
src/lib/co/src/co_time.c
View file @
314950e0
...
...
@@ -1069,9 +1069,23 @@ pwr_tStatus time_AsciiToTm(const char* tstr, struct tm* tmptr)
struct
tm
tt
;
int
i
;
pwr_tStatus
sts
;
int
monstr
=
0
;
sscanf
(
tstr
,
"%02d-%3c-%4d %02d:%02d:%02d"
,
&
tt
.
tm_mday
,
tmpMonStr
,
&
tt
.
tm_year
,
&
tt
.
tm_hour
,
&
tt
.
tm_min
,
&
tt
.
tm_sec
);
if
(
tstr
[
5
]
==
'-'
)
{
sscanf
(
tstr
,
"%02d-%02d-%4d %02d:%02d:%02d"
,
&
tt
.
tm_mday
,
&
tt
.
tm_mon
,
&
tt
.
tm_year
,
&
tt
.
tm_hour
,
&
tt
.
tm_min
,
&
tt
.
tm_sec
);
tt
.
tm_mon
--
;
}
else
if
(
tstr
[
4
]
==
'-'
)
{
sscanf
(
tstr
,
"%4d-%02d-%02d %02d:%02d:%02d"
,
&
tt
.
tm_year
,
&
tt
.
tm_mon
,
&
tt
.
tm_mday
,
&
tt
.
tm_hour
,
&
tt
.
tm_min
,
&
tt
.
tm_sec
);
tt
.
tm_mon
--
;
}
else
{
sscanf
(
tstr
,
"%02d-%3c-%4d %02d:%02d:%02d"
,
&
tt
.
tm_mday
,
tmpMonStr
,
&
tt
.
tm_year
,
&
tt
.
tm_hour
,
&
tt
.
tm_min
,
&
tt
.
tm_sec
);
monstr
=
1
;
}
tmpMonStr
[
3
]
=
'\0'
;
tt
.
tm_year
-=
1900
;
...
...
@@ -1083,14 +1097,16 @@ pwr_tStatus time_AsciiToTm(const char* tstr, struct tm* tmptr)
tt
.
tm_isdst
=
-
1
;
/* check month */
for
(
cp
=
tmpMonStr
;
*
cp
;
cp
++
)
*
cp
=
toupper
(
*
cp
);
tt
.
tm_mon
=
-
1
;
for
(
i
=
0
;
i
<
12
;
i
++
)
{
if
(
streq
(
tmpMonStr
,
monStr
[
i
]))
{
tt
.
tm_mon
=
i
;
break
;
if
(
monstr
)
{
for
(
cp
=
tmpMonStr
;
*
cp
;
cp
++
)
*
cp
=
toupper
(
*
cp
);
tt
.
tm_mon
=
-
1
;
for
(
i
=
0
;
i
<
12
;
i
++
)
{
if
(
streq
(
tmpMonStr
,
monStr
[
i
]))
{
tt
.
tm_mon
=
i
;
break
;
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment