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
72e44d59
Commit
72e44d59
authored
Jan 22, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/Format: add %iso8601%
parent
8f2ca8f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
user.xml
doc/user.xml
+5
-0
Format.cxx
src/tag/Format.cxx
+27
-0
No files found.
doc/user.xml
View file @
72e44d59
...
...
@@ -3192,6 +3192,11 @@ buffer_size: 16384</programlisting>
<para>
An alternative to
<varname>
path
</varname>
which
provides a format string referring to tag values.
The special tag
<varname>
iso8601
</varname>
emits
the current date and time in
<ulink
url=
"https://en.wikipedia.org/wiki/ISO_8601"
>
ISO8601
</ulink>
format (UTC).
Every time a new song starts or a new tag gets
received from a radio station, a new file is
opened. If the format does not render a file
...
...
src/tag/Format.cxx
View file @
72e44d59
...
...
@@ -26,6 +26,7 @@
#include <algorithm>
#include <string.h>
#include <time.h>
struct
FormatTagContext
{
const
Tag
&
tag
;
...
...
@@ -82,6 +83,32 @@ TagGetter(const void *object, const char *name)
{
const
auto
&
_ctx
=
*
(
const
FormatTagContext
*
)
object
;
auto
&
ctx
=
const_cast
<
FormatTagContext
&>
(
_ctx
);
if
(
strcmp
(
name
,
"iso8601"
)
==
0
)
{
time_t
t
=
time
(
nullptr
);
#ifdef WIN32
const
struct
tm
*
tm2
=
gmtime
(
&
t
);
#else
struct
tm
tm
;
const
struct
tm
*
tm2
=
gmtime_r
(
&
t
,
&
tm
);
#endif
if
(
tm2
==
nullptr
)
return
""
;
strftime
(
ctx
.
buffer
,
sizeof
(
ctx
.
buffer
),
#ifdef WIN32
/* kludge: use underscore instead of colon on
Windows because colons are not allowed in
file names, and this library is mostly
used to generate file names */
"%Y-%m-%dT%H_%M_%SZ"
,
#else
"%FT%TZ"
,
#endif
tm2
);
return
ctx
.
buffer
;
}
const
Tag
&
tag
=
ctx
.
tag
;
TagType
tag_type
=
tag_name_parse_i
(
name
);
...
...
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