Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: Confusing date behaviour.
#7
Here's the function if you want to add the line that strips the hyphens

/var/www/inc/music-library.php
Code:
// Priority: OriginalDate, OriginalReleaseDate, Date
function getTrackYear($trackData) {
    if (array_key_exists('OriginalDate', $trackData)) {
        $trackDate = $trackData['OriginalDate'];
    } else if (array_key_exists('OriginalReleaseDate', $trackData)) {
        $trackDate = $trackData['OriginalReleaseDate'];
    } else if (array_key_exists('Date', $trackData)) {
        $trackDate = $trackData['Date'];
    } else {
    $trackDate = '';
   }

   // Strip dashes from MusicBrainz dates (contrib: general@dlg.xyz)
   $trackDate = str_replace("-", "", $trackDate);
   // Set month to 00 if not present
   $trackYear = empty(substr($trackDate, 4, 2)) ? substr($trackDate, 0, 4) . '00' : substr($trackDate, 0, 6);

    return $trackYear;
}
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
Confusing date behaviour. - by the_bertrum - 03-05-2024, 01:10 PM
RE: Confusing date behaviour. - by the_bertrum - 03-05-2024, 02:31 PM
RE: Confusing date behaviour. - by Nutul - 03-05-2024, 04:20 PM
RE: Confusing date behaviour. - by the_bertrum - 03-05-2024, 06:56 PM
RE: Confusing date behaviour. - by Tim Curtis - 03-05-2024, 02:54 PM
RE: Confusing date behaviour. - by the_bertrum - 03-05-2024, 03:45 PM
RE: Confusing date behaviour. - by Tim Curtis - 03-05-2024, 04:50 PM
RE: Confusing date behaviour. - by the_bertrum - 03-05-2024, 06:47 PM
RE: Confusing date behaviour. - by the_bertrum - 03-05-2024, 07:05 PM
RE: Confusing date behaviour. - by DRONE7 - 03-06-2024, 05:09 AM
RE: Confusing date behaviour. - by the_bertrum - 03-06-2024, 07:35 AM
RE: Confusing date behaviour. - by DRONE7 - 03-06-2024, 08:41 AM

Forum Jump: