From 6e015b4cdbd33ff171ea6e9fa5506ded21d71fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kr=C3=B3l?= Date: Sun, 4 Aug 2013 09:52:36 +0200 Subject: [PATCH] Use uts instead of date['#text'] conversion --- lastfm.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lastfm.html b/lastfm.html index f0f8e4a..61165af 100644 --- a/lastfm.html +++ b/lastfm.html @@ -17,8 +17,7 @@

Recently Scrobbled

// Takes an ISO time and returns a string representing how // long ago the date represents. function prettyDate(time){ - var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")), - diff = (((new Date()).getTime() - date.getTime()) / 1000), + diff = ((new Date()).getTime()/1000 - time), day_diff = Math.floor(diff / 86400); if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 ) @@ -45,7 +44,8 @@

Recently Scrobbled

content = ''; $.each(json.recenttracks.track, function(i, track){ - content += '
  • ' + track.name +' by '+ track.artist['#text'] + ' ' + prettyDate(track.date['#text']) + ' ago
  • '; + var interval = prettyDate(track.date['uts']); + content += '
  • ' + track.name +' by '+ track.artist['#text'] + ' ' + interval + ' ago
  • '; }); tracklist.innerHTML = content;