aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emms-browser.el4
-rw-r--r--lisp/emms.el23
2 files changed, 25 insertions, 2 deletions
diff --git a/lisp/emms-browser.el b/lisp/emms-browser.el
index 414086c..6b6ce28 100644
--- a/lisp/emms-browser.el
+++ b/lisp/emms-browser.el
@@ -812,7 +812,7 @@ return an empty string."
(defun emms-browser-year-number (track)
"Return a string representation of a track's year.
This will be in the form '(1998) '."
- (let ((year (emms-track-get track 'info-year)))
+ (let ((year (emms-track-get-year track)))
(if (or (not (stringp year)) (string= year "0"))
""
(concat
@@ -1719,7 +1719,7 @@ If > album level, most of the track data will not make sense."
(format-choices
`(("i" . ,indent)
("n" . ,name)
- ("y" . ,(emms-track-get track 'info-year))
+ ("y" . ,(emms-track-get-year track))
("A" . ,(emms-track-get track 'info-album))
("a" . ,(emms-track-get track 'info-artist))
("C" . ,(emms-track-get track 'info-composer))
diff --git a/lisp/emms.el b/lisp/emms.el
index b91115e..0f2bd03 100644
--- a/lisp/emms.el
+++ b/lisp/emms.el
@@ -705,6 +705,29 @@ string), a confusing error message would result."
desc
(emms-track-simple-description track))))
+(defun emms-track-get-year (track)
+ "Get year of TRACK for display.
+There is the separation between the 'release date' and the
+'original date'. This difference matters e.g. for
+re-releases (anniversaries and such) where the release date is
+more recent than the original release date. In such cases the
+user probably wants the original release date so this is what we
+show."
+ (or
+ (emms-format-date-to-year (emms-track-get track 'info-date))
+ (emms-format-date-to-year (emms-track-get track 'info-originaldate))
+ (emms-track-get track 'info-year)
+ (emms-track-get track 'info-originalyear)))
+
+(defun emms-format-date-to-year (date)
+ "Try to extract year part from DATE.
+Return nil if the year cannot be extracted."
+ (when date
+ (let ((year (nth 5 (parse-time-string date))))
+ (if year (number-to-string year)
+ (when (string-match "^[ \t]*\\([0-9]\\{4\\}\\)" date)
+ (match-string 1 date))))))
+
;;; The Playlist