mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
[pixiv] work around strptime limitations in Python < 3.7
"%z" doesn't allow a colon separator in older Python versions: - "+0900" is OK - "+09:00" raises an exception
This commit is contained in:
parent
1f7fa9dc8e
commit
4736912d4e
@ -42,7 +42,7 @@ class PixivExtractor(Extractor):
|
|||||||
del work["meta_pages"]
|
del work["meta_pages"]
|
||||||
work["num"] = ""
|
work["num"] = ""
|
||||||
work["tags"] = [tag["name"] for tag in work["tags"]]
|
work["tags"] = [tag["name"] for tag in work["tags"]]
|
||||||
work["date"] = text.parse_datetime(work["create_date"])
|
work["date"] = text.parse_datetime(work["create_date"][:-3] + "00")
|
||||||
work.update(metadata)
|
work.update(metadata)
|
||||||
|
|
||||||
yield Message.Directory, work
|
yield Message.Directory, work
|
||||||
|
@ -353,11 +353,11 @@ class TestText(unittest.TestCase):
|
|||||||
def test_parse_datetime(self, f=text.parse_datetime):
|
def test_parse_datetime(self, f=text.parse_datetime):
|
||||||
null = datetime.datetime.utcfromtimestamp(0)
|
null = datetime.datetime.utcfromtimestamp(0)
|
||||||
|
|
||||||
self.assertEqual(f("1970-01-01T00:00:00+00:00"), null)
|
self.assertEqual(f("1970-01-01T00:00:00+0000"), null)
|
||||||
self.assertEqual(f("1970.01.01", "%Y.%m.%d") , null)
|
self.assertEqual(f("1970.01.01", "%Y.%m.%d") , null)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
f("2019-05-07T21:25:02+09:00"),
|
f("2019-05-07T21:25:02+0900"),
|
||||||
datetime.datetime(2019, 5, 7, 12, 25, 2),
|
datetime.datetime(2019, 5, 7, 12, 25, 2),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user