Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
asapo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joao Alvim Oliveira Dias De Almeida
asapo
Commits
191ef13d
Commit
191ef13d
authored
5 years ago
by
Sergey Yakubov
Browse files
Options
Downloads
Patches
Plain Diff
do not use put_time
parent
33e388ae
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/cpp/src/data_structs/data_structs.cpp
+14
-8
14 additions, 8 deletions
common/cpp/src/data_structs/data_structs.cpp
worker/tools/folder_to_db/unittests/test_folder_to_db.cpp
+7
-3
7 additions, 3 deletions
worker/tools/folder_to_db/unittests/test_folder_to_db.cpp
with
21 additions
and
11 deletions
common/cpp/src/data_structs/data_structs.cpp
+
14
−
8
View file @
191ef13d
...
...
@@ -99,19 +99,25 @@ std::string IsoDateFromEpochNanosecs(uint64_t time_from_epoch_nanosec) {
std
::
tm
timetm
=
*
std
::
gmtime
(
&
time
);
std
::
stringstream
ssTp
;
auto
zz
=
time_from_epoch_nanosec
%
1000000000
;
ssTp
<<
std
::
put_time
(
&
timetm
,
"%Y-%m-%dT%H:%M:%S"
);
std
::
string
s
;
char
buff
[
100
];
sprintf
(
buff
,
"%.4d-%.2d-%.2dT%.2d:%.2d:%.2d"
,
timetm
.
tm_year
+
1900
,
timetm
.
tm_mon
+
1
,
timetm
.
tm_mday
,
timetm
.
tm_hour
,
timetm
.
tm_min
,
timetm
.
tm_sec
);
if
(
zz
>
0
)
{
s
sTp
<<
"."
<<
std
::
setw
(
9
)
<<
std
::
setfill
(
'0'
)
<<
zz
;
s
printf
(
buff
+
19
,
".%.9ld"
,
zz
)
;
}
return
ssTp
.
str
();
return
buff
;
}
uint64_t
NanosecsEpochFromISODate
(
std
::
string
date_time
)
{
double
frac
=
0
;
int
pos
=
date_time
.
find_first_of
(
'.'
);
if
(
pos
!=
std
::
string
::
npos
)
{
if
(
pos
!=
std
::
string
::
npos
)
{
std
::
string
frac_str
=
date_time
.
substr
(
pos
);
if
(
sscanf
(
frac_str
.
c_str
(),
"%lf"
,
&
frac
)
!=
1
)
{
if
(
sscanf
(
frac_str
.
c_str
(),
"%lf"
,
&
frac
)
!=
1
)
{
return
0
;
}
date_time
=
date_time
.
substr
(
0
,
pos
);
...
...
@@ -128,7 +134,7 @@ uint64_t NanosecsEpochFromISODate(std::string date_time) {
if
(
!
(
year
>=
1970
&&
month
>=
1
&&
month
<=
12
&&
day
>=
1
&&
day
<=
31
)
||
(
n
!=
3
&&
n
!=
6
))
{
return
0
;
}
if
((
n
==
3
&&
date_time
.
size
()
!=
10
)
||
(
n
==
6
&&
date_time
.
size
()
!=
19
))
{
if
((
n
==
3
&&
date_time
.
size
()
!=
10
)
||
(
n
==
6
&&
date_time
.
size
()
!=
19
))
{
return
0
;
}
...
...
@@ -136,8 +142,8 @@ uint64_t NanosecsEpochFromISODate(std::string date_time) {
tm
.
tm_min
=
minute
;
tm
.
tm_hour
=
hour
;
tm
.
tm_mday
=
day
;
tm
.
tm_mon
=
month
-
1
;
tm
.
tm_year
=
year
-
1900
;
tm
.
tm_mon
=
month
-
1
;
tm
.
tm_year
=
year
-
1900
;
system_clock
::
time_point
tp
=
system_clock
::
from_time_t
(
timegm
(
&
tm
));
uint64_t
ns
=
std
::
chrono
::
time_point_cast
<
std
::
chrono
::
nanoseconds
>
(
tp
).
...
...
This diff is collapsed.
Click to expand it.
worker/tools/folder_to_db/unittests/test_folder_to_db.cpp
+
7
−
3
View file @
191ef13d
...
...
@@ -22,6 +22,7 @@
using
::
testing
::
AtLeast
;
using
::
testing
::
Eq
;
using
::
testing
::
Gt
;
using
::
testing
::
Ge
;
using
::
testing
::
Ne
;
using
::
testing
::
Test
;
using
::
testing
::
_
;
...
...
@@ -247,13 +248,16 @@ TEST_F(FolderDBConverterTests, ComputesStatistics) {
WillRepeatedly
(
testing
::
Return
(
nullptr
));
asapo
::
FolderImportStatistics
statistics
;
statistics
.
time_read_folder
=
std
::
chrono
::
nanoseconds
{
-
1
};
statistics
.
time_import_files
=
std
::
chrono
::
nanoseconds
{
-
1
};
auto
error
=
converter
.
Convert
(
uri
,
folder
,
db_name
,
&
statistics
);
ASSERT_THAT
(
error
,
Eq
(
nullptr
));
ASSERT_THAT
(
statistics
.
n_files_converted
,
Eq
(
file_infos
.
size
()));
// tests may fail is function call is smaller than 1 ns
ASSERT_THAT
(
statistics
.
time_read_folder
.
count
(),
Gt
(
0
));
ASSERT_THAT
(
statistics
.
time_import_files
.
count
(),
Gt
(
0
));
ASSERT_THAT
(
statistics
.
time_read_folder
.
count
(),
Ge
(
0
));
ASSERT_THAT
(
statistics
.
time_import_files
.
count
(),
Ge
(
0
));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment