MPD: More correct date format in listplaylists output
This commit is contained in:
parent
2f9775250a
commit
bcc133a079
@ -1506,9 +1506,14 @@ class MpdFrontend(object):
|
|||||||
result = []
|
result = []
|
||||||
for playlist in self.backend.stored_playlists.playlists:
|
for playlist in self.backend.stored_playlists.playlists:
|
||||||
result.append((u'playlist', playlist.name))
|
result.append((u'playlist', playlist.name))
|
||||||
# TODO Remove microseconds and add time zone information
|
last_modified = (playlist.last_modified or
|
||||||
result.append((u'Last-Modified',
|
dt.datetime.now()).isoformat()
|
||||||
(playlist.last_modified or dt.datetime.now()).isoformat()))
|
# Remove microseconds
|
||||||
|
last_modified = last_modified.split('.')[0]
|
||||||
|
# Add time zone information
|
||||||
|
# TODO Convert to UTC before adding Z
|
||||||
|
last_modified = last_modified + 'Z'
|
||||||
|
result.append((u'Last-Modified', last_modified))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@handle_pattern(r'^load "(?P<name>[^"]+)"$')
|
@handle_pattern(r'^load "(?P<name>[^"]+)"$')
|
||||||
|
|||||||
@ -894,12 +894,13 @@ class StoredPlaylistsHandlerTest(unittest.TestCase):
|
|||||||
u'ACK [50@0] {listplaylistinfo} No such playlist')
|
u'ACK [50@0] {listplaylistinfo} No such playlist')
|
||||||
|
|
||||||
def test_listplaylists(self):
|
def test_listplaylists(self):
|
||||||
last_modified = dt.datetime(2001, 3, 17, 13, 41, 17)
|
last_modified = dt.datetime(2001, 3, 17, 13, 41, 17, 12345)
|
||||||
self.b.stored_playlists.playlists = [Playlist(name='a',
|
self.b.stored_playlists.playlists = [Playlist(name='a',
|
||||||
last_modified=last_modified)]
|
last_modified=last_modified)]
|
||||||
result = self.h.handle_request(u'listplaylists')
|
result = self.h.handle_request(u'listplaylists')
|
||||||
self.assert_(u'playlist: a' in result)
|
self.assert_(u'playlist: a' in result)
|
||||||
self.assert_(u'Last-Modified: 2001-03-17T13:41:17' in result)
|
# Date without microseconds and with time zone information
|
||||||
|
self.assert_(u'Last-Modified: 2001-03-17T13:41:17Z' in result)
|
||||||
self.assert_(u'OK' in result)
|
self.assert_(u'OK' in result)
|
||||||
|
|
||||||
def test_load(self):
|
def test_load(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user