From 6f879004fc0419da39b80ad14655085762a0ee7a Mon Sep 17 00:00:00 2001 From: gballan1 Date: Tue, 29 Nov 2016 12:06:26 -0500 Subject: [PATCH] Fix for album release info --- app/Fieldprotocol/Music/Album.php | 2 +- public/js/music.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Fieldprotocol/Music/Album.php b/app/Fieldprotocol/Music/Album.php index 4142873..e6910ab 100644 --- a/app/Fieldprotocol/Music/Album.php +++ b/app/Fieldprotocol/Music/Album.php @@ -20,7 +20,7 @@ class Album extends Eloquent { } public function releaseDate() { - return date('F jS, Y', strtotime($this->release_date)); + return date('F j, Y', strtotime($this->release_date)); } public function releaseYear() { diff --git a/public/js/music.js b/public/js/music.js index d30f805..8047f49 100755 --- a/public/js/music.js +++ b/public/js/music.js @@ -46,12 +46,28 @@ function getAlbumInfo(albumElem) { // change album title $('#album-title').text(json.title); // change album release date - $('#album-release span').text(new Date(json.release_date, "January 25 2015")); + $('#album-release span').text(formatReleaseDate(json.release_date)); // change album description $('#album-description').text(json.description); }); } +function formatReleaseDate(d) { + var monthNames = [ + "January", "February", "March", + "April", "May", "June", "July", + "August", "September", "October", + "November", "December" + ]; + + var date = new Date(d); + var day = date.getDate(); + var monthIndex = date.getMonth(); + var year = date.getFullYear(); + + return monthNames[monthIndex] + ' ' + day + ', ' + year; +} + function getAlbumSongs(albumElem) { albumElem = $(albumElem).parent();