Skip to content

Commit

Permalink
Convert datetime objects to local time when reading in
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Hadley committed May 11, 2023
1 parent 97a3066 commit 81bbaf3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Changed

- `ParamDB.commit()` returns the ID of the newly created commit.
- `ParamDB.load()` converts `datetime` objects to local time regardless of the timezone
stored internally in the database.

## [0.6.0] (May 3 2023)

Expand Down
2 changes: 1 addition & 1 deletion paramdb/_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _from_dict(json_dict: dict[str, Any]) -> Any:
return json_dict
class_name = json_dict.pop(CLASS_NAME_KEY)
if class_name == _full_class_name(datetime):
return datetime.fromisoformat(json_dict["isoformat"])
return datetime.fromisoformat(json_dict["isoformat"]).astimezone()
if ASTROPY_INSTALLED and class_name == _full_class_name(Quantity):
return Quantity(**json_dict)
param_class = get_param_class(class_name)
Expand Down

0 comments on commit 81bbaf3

Please sign in to comment.