diff --git a/docs/changes.rst b/docs/changes.rst index 6a5aa572..18c1f0ad 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -27,6 +27,12 @@ v0.11.0 (in development) - Add empty stubs for channel commands for client to client communication. +**Internal changes** + +*Models:* + +- Specified that :attr:`mopidy.models.Playlist.last_modified` should be in UTC. + v0.10.0 (2012-12-12) ==================== diff --git a/mopidy/frontends/mpd/protocol/stored_playlists.py b/mopidy/frontends/mpd/protocol/stored_playlists.py index 034403ec..b1fe87de 100644 --- a/mopidy/frontends/mpd/protocol/stored_playlists.py +++ b/mopidy/frontends/mpd/protocol/stored_playlists.py @@ -82,11 +82,10 @@ def listplaylists(context): continue result.append(('playlist', playlist.name)) last_modified = ( - playlist.last_modified or dt.datetime.now()).isoformat() + playlist.last_modified or dt.datetime.utcnow()).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(('Last-Modified', last_modified)) return result diff --git a/mopidy/models.py b/mopidy/models.py index a4ed1b4f..e47ed3be 100644 --- a/mopidy/models.py +++ b/mopidy/models.py @@ -290,7 +290,7 @@ class Playlist(ImmutableObject): :type name: string :param tracks: playlist's tracks :type tracks: list of :class:`Track` elements - :param last_modified: playlist's modification time + :param last_modified: playlist's modification time in UTC :type last_modified: :class:`datetime.datetime` """ @@ -303,7 +303,7 @@ class Playlist(ImmutableObject): #: The playlist's tracks. Read-only. tracks = tuple() - #: The playlist modification time. Read-only. + #: The playlist modification time in UTC. Read-only. #: #: :class:`datetime.datetime`, or :class:`None` if unknown. last_modified = None diff --git a/tests/models_test.py b/tests/models_test.py index 9a3062fc..1a4d869a 100644 --- a/tests/models_test.py +++ b/tests/models_test.py @@ -707,7 +707,7 @@ class PlaylistTest(unittest.TestCase): self.assertEqual(playlist.length, 3) def test_last_modified(self): - last_modified = datetime.datetime.now() + last_modified = datetime.datetime.utcnow() playlist = Playlist(last_modified=last_modified) self.assertEqual(playlist.last_modified, last_modified) self.assertRaises( @@ -715,7 +715,7 @@ class PlaylistTest(unittest.TestCase): def test_with_new_uri(self): tracks = [Track()] - last_modified = datetime.datetime.now() + last_modified = datetime.datetime.utcnow() playlist = Playlist( uri='an uri', name='a name', tracks=tracks, last_modified=last_modified) @@ -727,7 +727,7 @@ class PlaylistTest(unittest.TestCase): def test_with_new_name(self): tracks = [Track()] - last_modified = datetime.datetime.now() + last_modified = datetime.datetime.utcnow() playlist = Playlist( uri='an uri', name='a name', tracks=tracks, last_modified=last_modified) @@ -739,7 +739,7 @@ class PlaylistTest(unittest.TestCase): def test_with_new_tracks(self): tracks = [Track()] - last_modified = datetime.datetime.now() + last_modified = datetime.datetime.utcnow() playlist = Playlist( uri='an uri', name='a name', tracks=tracks, last_modified=last_modified) @@ -752,7 +752,7 @@ class PlaylistTest(unittest.TestCase): def test_with_new_last_modified(self): tracks = [Track()] - last_modified = datetime.datetime.now() + last_modified = datetime.datetime.utcnow() new_last_modified = last_modified + datetime.timedelta(1) playlist = Playlist( uri='an uri', name='a name', tracks=tracks,