summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/decoder/plugins/SidplayDecoderPlugin.cxx26
2 files changed, 26 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 1ca3a3123..acc735d2e 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ ver 0.21.14 (not yet released)
* decoder
- sidplay: show track durations in database
- sidplay: convert tag values from Windows-1252 charset
+ - sidplay: strip text from "Date" tag
ver 0.21.13 (2019/08/06)
* input
diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx
index 619ef38f6..8a22e0817 100644
--- a/src/decoder/plugins/SidplayDecoderPlugin.cxx
+++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx
@@ -477,6 +477,30 @@ GetInfoString(const SidTuneInfo &info, unsigned i) noexcept
return Windows1252ToUTF8(s);
}
+gcc_pure
+static AllocatedString<char>
+GetDateString(const SidTuneInfo &info) noexcept
+{
+ /*
+ * Field 2 is called <released>, previously used as <copyright>.
+ * It is formatted <year><space><company or author or group>,
+ * where <year> may be <YYYY>, <YYY?>, <YY??> or <YYYY-YY>, for
+ * example "1987", "199?", "19??" or "1985-87". The <company or
+ * author or group> may be for example Rob Hubbard. A full field
+ * may be for example "1987 Rob Hubbard".
+ */
+ AllocatedString<char> release = GetInfoString(info, 2);
+
+ /* Keep the <year> part only for the date. */
+ for (size_t i = 0; release[i] != AllocatedString<char>::SENTINEL; i++)
+ if (std::isspace(release[i])) {
+ release[i] = AllocatedString<char>::SENTINEL;
+ break;
+ }
+
+ return release;
+}
+
static void
ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
TagHandler &handler) noexcept
@@ -498,7 +522,7 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
handler.OnTag(TAG_ARTIST, artist.c_str());
/* date */
- const auto date = GetInfoString(info, 2);
+ const auto date = GetDateString(info);
if (!date.empty())
handler.OnTag(TAG_DATE, date.c_str());