diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c9e1d8b2d2d8bfe8301bcb778acb4f1e31148e6..6c41991a8745df13ec99683d37a6539b3888d72e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### +* Add TimeZone class and parse the server's time zone in the Info response. + ### Changed ### * Set PyYAML dependency back to PyYaml>=5.4.1 (from 6.0) for better diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index f974060f4727e575a94a3afcdd2f86520e6123a9..7000ede917995c6c01b78a822c2d39ac626fcc23 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -51,6 +51,7 @@ from caosdb.common.datatype import (BOOLEAN, DATETIME, DOUBLE, INTEGER, TEXT, is_list_datatype, is_reference) from caosdb.common.state import State from caosdb.common.utils import uuid, xml2str +from caosdb.common.timezone import TimeZone from caosdb.common.versioning import Version from caosdb.configuration import get_config from caosdb.connection.connection import get_connection @@ -4327,6 +4328,8 @@ class Info(): if isinstance(m, UserInfo): self.user_info = m + elif isinstance(m, TimeZone): + self.time_zone = m else: self.messages.append(m) @@ -4460,6 +4463,9 @@ def _parse_single_xml_element(elem): return Permissions(xml=elem) elif elem.tag == "UserInfo": return UserInfo(xml=elem) + elif elem.tag == "TimeZone": + return TimeZone(zone_id=elem.get("id"), offset=elem.get("offset"), + display_name=elem.text.strip()) else: return Message(type=elem.tag, code=elem.get( "code"), description=elem.get("description"), body=elem.text) diff --git a/src/caosdb/common/timezone.py b/src/caosdb/common/timezone.py new file mode 100644 index 0000000000000000000000000000000000000000..2bd3d3d4d739118e160f7b3a35757fbb0afe70cb --- /dev/null +++ b/src/caosdb/common/timezone.py @@ -0,0 +1,18 @@ +class TimeZone(): + """ + TimeZone, e.g. CEST, Europe/Berlin, UTC+4. + + + Attributes + ---------- + zone_id : string + ID of the time zone. + offset : int + Offset to UTC in seconds. + display_name : string + A human-friendly name of the time zone: + """ + def __init__(self, zone_id, offset, display_name): + self.zone_id = zone_id + self.offset = offset + self.display_name = display_name