update hydroshare version fetch to assume timestamp is in utc
MODIFY
repo2docker/contentproviders/hydroshare.py
repo2docker/contentproviders/hydroshare.py
@@ -3,7 +3,7 @@ import os
import shutil
import time
import json
-import datetime
+from datetime import datetime, timezone, timedelta
from urllib.request import urlopen, Request, urlretrieve
from urllib.error import HTTPError
@@ -37,7 +37,12 @@ class Hydroshare(DoiProvider):
date = next(
item for item in json_response["dates"] if item["type"] == "modified"
)["start_date"]
- return datetime.strptime(date, "%Y-%m-%dT%H:%M:%S").timestamp()
+ # Hydroshare timestamp always returns the same timezone, so strip it
+ date = date.split(".")[0]
+ parsed_date = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S")
+ epoch = parsed_date.replace(tzinfo=timezone(timedelta(0))).timestamp()
+ # truncate the timestamp
+ return str(int(epoch))
url = self.doi2url(doi)

MODIFY
tests/unit/contentproviders/test_hydroshare.py
tests/unit/contentproviders/test_hydroshare.py
@@ -26,7 +26,7 @@ def test_content_id():
hydro = Hydroshare()
hydro.detect("10.4211/hs.b8f6eae9d89241cf8b5904033460af61")
- assert hydro.content_id == "b8f6eae9d89241cf8b5904033460af61.v1569449357"
+ assert hydro.content_id == "b8f6eae9d89241cf8b5904033460af61.v1569427757"
test_hosts = [
@@ -46,7 +46,7 @@ test_hosts = [
"version": "https://www.hydroshare.org/hsapi/resource/{}/scimeta/elements",
},
"resource": "b8f6eae9d89241cf8b5904033460af61",
- "version": "1569449357",
+ "version": "1569427757",
},
)
]

update hydroshare version fetch to assume timestamp is in utc