Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
b2b079a2
Commit
b2b079a2
authored
Jan 18, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SongFilter: use std::chrono::system_clock::time_point instead of time_t
parent
b886dfae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
SongFilter.cxx
src/SongFilter.cxx
+12
-11
SongFilter.hxx
src/SongFilter.hxx
+3
-3
No files found.
src/SongFilter.cxx
View file @
b2b079a2
...
...
@@ -22,6 +22,7 @@
#include "db/LightSong.hxx"
#include "DetachedSong.hxx"
#include "tag/ParseName.hxx"
#include "util/ChronoUtil.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringAPI.hxx"
#include "util/ASCII.hxx"
...
...
@@ -71,7 +72,8 @@ SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case)
{
}
SongFilter
::
Item
::
Item
(
unsigned
_tag
,
time_t
_time
)
SongFilter
::
Item
::
Item
(
unsigned
_tag
,
std
::
chrono
::
system_clock
::
time_point
_time
)
:
tag
(
_tag
),
value
(
nullptr
),
time
(
_time
)
{
}
...
...
@@ -145,7 +147,7 @@ SongFilter::Item::Match(const DetachedSong &song) const noexcept
return
uri_is_child_or_same
(
value
.
c_str
(),
song
.
GetURI
());
if
(
tag
==
LOCATE_TAG_MODIFIED_SINCE
)
return
song
.
GetLastModified
()
>=
std
::
chrono
::
system_clock
::
from_time_t
(
time
)
;
return
song
.
GetLastModified
()
>=
time
;
if
(
tag
==
LOCATE_TAG_FILE_TYPE
)
return
StringMatch
(
song
.
GetURI
());
...
...
@@ -162,7 +164,7 @@ SongFilter::Item::Match(const LightSong &song) const noexcept
}
if
(
tag
==
LOCATE_TAG_MODIFIED_SINCE
)
return
song
.
mtime
>=
std
::
chrono
::
system_clock
::
from_time_t
(
time
)
;
return
song
.
mtime
>=
time
;
if
(
tag
==
LOCATE_TAG_FILE_TYPE
)
{
const
auto
uri
=
song
.
GetURI
();
...
...
@@ -183,8 +185,8 @@ SongFilter::~SongFilter()
}
gcc_pure
static
time_
t
ParseTimeStamp
(
const
char
*
s
)
noexcept
static
std
::
chrono
::
system_clock
::
time_poin
t
ParseTimeStamp
(
const
char
*
s
)
{
assert
(
s
!=
nullptr
);
...
...
@@ -192,14 +194,13 @@ ParseTimeStamp(const char *s) noexcept
unsigned
long
long
value
=
strtoull
(
s
,
&
endptr
,
10
);
if
(
*
endptr
==
0
&&
endptr
>
s
)
/* it's an integral UNIX time stamp */
return
(
time_t
)
value
;
return
std
::
chrono
::
system_clock
::
from_time_t
((
time_t
)
value
)
;
try
{
/* try ISO 8601 */
const
auto
t
=
ParseTimePoint
(
s
,
"%FT%TZ"
);
return
std
::
chrono
::
system_clock
::
to_time_t
(
t
);
return
ParseTimePoint
(
s
,
"%FT%TZ"
);
}
catch
(
const
std
::
runtime_error
&
)
{
return
0
;
return
std
::
chrono
::
system_clock
::
time_point
::
min
()
;
}
}
...
...
@@ -219,8 +220,8 @@ SongFilter::Parse(const char *tag_string, const char *value, bool fold_case)
}
if
(
tag
==
LOCATE_TAG_MODIFIED_SINCE
)
{
time_t
t
=
ParseTimeStamp
(
value
);
if
(
t
==
0
)
const
auto
t
=
ParseTimeStamp
(
value
);
if
(
IsNegative
(
t
)
)
return
false
;
items
.
push_back
(
Item
(
tag
,
t
));
...
...
src/SongFilter.hxx
View file @
b2b079a2
...
...
@@ -24,9 +24,9 @@
#include "Compiler.h"
#include <list>
#include <chrono>
#include <stdint.h>
#include <time.h>
/**
* Limit the search to files within the given directory.
...
...
@@ -55,12 +55,12 @@ public:
/**
* For #LOCATE_TAG_MODIFIED_SINCE
*/
time_
t
time
;
std
::
chrono
::
system_clock
::
time_poin
t
time
;
public
:
gcc_nonnull
(
3
)
Item
(
unsigned
tag
,
const
char
*
value
,
bool
fold_case
=
false
);
Item
(
unsigned
tag
,
time_
t
time
);
Item
(
unsigned
tag
,
std
::
chrono
::
system_clock
::
time_poin
t
time
);
Item
(
const
Item
&
other
)
=
delete
;
Item
(
Item
&&
)
=
default
;
...
...
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