Notification: Fix album date assignment

The NSCalendar assignment should have a placeholder month and day
of January 1st, instead of the invalid month/day of 0/0. Also,
even if this somehow fails, don't attempt to assign it if it
returns nil.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2025-01-03 01:28:07 -08:00
parent 925a3502fa
commit 91b31255e6

View file

@ -948,8 +948,10 @@ NSDictionary *makeRGInfo(PlaylistEntry *pe) {
if(entry.year) {
// If PlaylistEntry can represent a full date like some tag formats can do, change it
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *releaseYear = [calendar dateWithEra:1 year:entry.year month:0 day:0 hour:0 minute:0 second:0 nanosecond:0];
[songInfo setObject:releaseYear forKey:MPMediaItemPropertyReleaseDate];
NSDate *releaseYear = [calendar dateWithEra:1 year:entry.year month:1 day:1 hour:0 minute:0 second:0 nanosecond:0];
if(releaseYear) {
[songInfo setObject:releaseYear forKey:MPMediaItemPropertyReleaseDate];
}
}
[songInfo setObject:@(entry.currentPosition) forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
[songInfo setObject:entry.length forKey:MPMediaItemPropertyPlaybackDuration];