diff --git a/fimfarchive/mappers.py b/fimfarchive/mappers.py index 380286b..515d05a 100644 --- a/fimfarchive/mappers.py +++ b/fimfarchive/mappers.py @@ -24,6 +24,8 @@ Mappers for Fimfarchive. import os +import arrow + from fimfarchive.exceptions import InvalidStoryError @@ -80,7 +82,7 @@ class StoryDateMapper(Mapper): dates.discard(None) if dates: - return max(dates) + return max(arrow.get(date) for date in dates) else: return None diff --git a/requirements.txt b/requirements.txt index 14f5624..0bc4ef1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +arrow blinker jmespath requests diff --git a/tests/test_mappers.py b/tests/test_mappers.py index eb63dd3..47d4974 100644 --- a/tests/test_mappers.py +++ b/tests/test_mappers.py @@ -151,7 +151,7 @@ class TestStoryDateMapper: story = story.merge(meta=meta) - assert mapper(story) == 5 + assert mapper(story).timestamp == 5 def test_meta_with_none_chapters(self, mapper, story): """ @@ -164,7 +164,7 @@ class TestStoryDateMapper: story = story.merge(meta=meta) - assert mapper(story) == 5 + assert mapper(story).timestamp == 5 def test_meta_with_empty_chapters(self, mapper, story): """ @@ -177,7 +177,7 @@ class TestStoryDateMapper: story = story.merge(meta=meta) - assert mapper(story) == 5 + assert mapper(story).timestamp == 5 def test_meta_with_only_chapter_dates(self, mapper, story): """ @@ -193,7 +193,7 @@ class TestStoryDateMapper: story = story.merge(meta=meta) - assert mapper(story) == 5 + assert mapper(story).timestamp == 5 def test_meta_with_only_story_date(self, mapper, story): """ @@ -210,7 +210,7 @@ class TestStoryDateMapper: story = story.merge(meta=meta) - assert mapper(story) == 5 + assert mapper(story).timestamp == 5 def test_meta_with_latest_chapter_date(self, mapper, story): """ @@ -227,7 +227,7 @@ class TestStoryDateMapper: story = story.merge(meta=meta) - assert mapper(story) == 5 + assert mapper(story).timestamp == 5 def test_meta_with_latest_story_date(self, mapper, story): """ @@ -244,7 +244,7 @@ class TestStoryDateMapper: story = story.merge(meta=meta) - assert mapper(story) == 5 + assert mapper(story).timestamp == 5 def test_meta_with_both_latest(self, mapper, story): """ @@ -261,7 +261,7 @@ class TestStoryDateMapper: story = story.merge(meta=meta) - assert mapper(story) == 5 + assert mapper(story).timestamp == 5 class TestStoryPathMapper: