diff --git a/swh/deposit/tests/api/test_deposit_private_read_metadata.py b/swh/deposit/tests/api/test_deposit_private_read_metadata.py --- a/swh/deposit/tests/api/test_deposit_private_read_metadata.py +++ b/swh/deposit/tests/api/test_deposit_private_read_metadata.py @@ -83,12 +83,10 @@ "author": SWH_PERSON, "committer": SWH_PERSON, "committer_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, "author_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, @@ -157,12 +155,10 @@ "author": SWH_PERSON, "committer": SWH_PERSON, "committer_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, "author_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, @@ -233,12 +229,10 @@ "author": SWH_PERSON, "committer": SWH_PERSON, "committer_date": { - "negative_utc": False, "offset": 120, "timestamp": {"microseconds": 0, "seconds": 1493820527}, }, "author_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, @@ -293,12 +287,10 @@ "author": SWH_PERSON, "committer": SWH_PERSON, "committer_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1459900800}, }, "author_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1459900800}, }, @@ -366,12 +358,10 @@ "author": SWH_PERSON, "committer": SWH_PERSON, "committer_date": { - "negative_utc": False, "offset": 120, "timestamp": {"microseconds": 0, "seconds": 1493820527}, }, "author_date": { - "negative_utc": False, "offset": 120, "timestamp": {"microseconds": 0, "seconds": 1428332927}, }, @@ -450,12 +440,10 @@ "author": SWH_PERSON, "committer": SWH_PERSON, "committer_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, "author_date": { - "negative_utc": False, "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428}, }, diff --git a/swh/deposit/tests/loader/data/https_deposit.softwareheritage.org/1_private_test_999_meta b/swh/deposit/tests/loader/data/https_deposit.softwareheritage.org/1_private_test_999_meta --- a/swh/deposit/tests/loader/data/https_deposit.softwareheritage.org/1_private_test_999_meta +++ b/swh/deposit/tests/loader/data/https_deposit.softwareheritage.org/1_private_test_999_meta @@ -40,7 +40,6 @@ "email": "robot@softwareheritage.org" }, "committer_date": { - "negative_utc": "false", "offset": 0, "timestamp": { "microseconds": 0, @@ -48,7 +47,6 @@ } }, "date": { - "negative_utc": "false", "offset": 0, "timestamp": {"microseconds": 0, "seconds": 1507389428} }, diff --git a/swh/deposit/tests/test_utils.py b/swh/deposit/tests/test_utils.py --- a/swh/deposit/tests/test_utils.py +++ b/swh/deposit/tests/test_utils.py @@ -120,7 +120,6 @@ assert actual_date == { "timestamp": {"microseconds": 0, "seconds": 1507766400}, - "negative_utc": False, "offset": 0, } @@ -132,7 +131,6 @@ assert actual_date == { "timestamp": {"microseconds": 0, "seconds": 1528736522}, - "negative_utc": False, "offset": 0, } @@ -145,7 +143,6 @@ assert actual_date == { "timestamp": {"seconds": 1483228800, "microseconds": 0}, "offset": 0, - "negative_utc": False, } diff --git a/swh/deposit/utils.py b/swh/deposit/utils.py --- a/swh/deposit/utils.py +++ b/swh/deposit/utils.py @@ -109,15 +109,12 @@ if isinstance(date, str): date = iso8601.parse_date(date) - d = TimestampWithTimezone.from_dict(date).to_dict() + tstz = TimestampWithTimezone.from_dict(date) - # Workaround while we migrate from storing offsets as (int, bool) to bytes. - # When the migration is done, remove this pop(). - # offset_bytes will also need to be converted to a string (which is fine because - # it is always a well-formed offset) - d.pop("offset_bytes", None) - - return d + return { + "timestamp": tstz.timestamp.to_dict(), + "offset": tstz.offset, + } def compute_metadata_context(swhid_reference: QualifiedSWHID) -> Dict[str, Any]: