Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add datetime parsing in cleanrecord
Browse files Browse the repository at this point in the history
Lash-L committed Sep 9, 2023
1 parent 907ed06 commit a27c4d2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions roborock/containers.py
Original file line number Diff line number Diff line change
@@ -408,7 +408,9 @@ def __post_init__(self) -> None:
@dataclass
class CleanRecord(RoborockBase):
begin: Optional[int] = None
begin_datetime: datetime.datetime | None = None
end: Optional[int] = None
end_datetime: datetime.datetime | None = None
duration: Optional[int] = None
area: Optional[int] = None
square_meter_area: Optional[float] = None
@@ -424,6 +426,8 @@ class CleanRecord(RoborockBase):

def __post_init__(self) -> None:
self.square_meter_area = round(self.area / 1000000, 1) if self.area is not None else None
self.begin_datetime = datetime.datetime.fromtimestamp(self.begin).astimezone(datetime.UTC) if self.begin else None
self.end_datetime = datetime.datetime.fromtimestamp(self.end).astimezone(datetime.UTC) if self.end else None


@dataclass

0 comments on commit a27c4d2

Please sign in to comment.