Skip to content

core: add itemtypes datetime and timestamp#772

Merged
Morg42 merged 3 commits intosmarthomeNG:developfrom
Morg42:datetime
Apr 1, 2026
Merged

core: add itemtypes datetime and timestamp#772
Morg42 merged 3 commits intosmarthomeNG:developfrom
Morg42:datetime

Conversation

@Morg42
Copy link
Copy Markdown
Member

@Morg42 Morg42 commented Mar 25, 2026

Adds item types datetime (datetime.datetime object) and timestamp (POSIX timestamp implemented as float).

datetime items have additional methods item.as_ts() and item.as_str(format), which output timestamp or text respectively. format parameter is optional (as for strftime), None means ISO format.

timestamp items have additional methods item.as_dt() and item.as_str(format), which output datetime or text respectively. format parameter is optional (as for strftime), None means ISO format.

As of now, both types can not be edited in AdminUI as they are not yet implemented there; both will be displayed correctly. I modified the Admin-Module as to enable transferring datetime as JSON (json.encode added the default=str parameter). This might have to be revisited later, as of now, I see no problems.

Feel free to try out and find errors ;) most probably in timezone conversion, though I tried to work with tz-aware datetimes everywhere and get the timezone from shtime.tzinfo().

Oh, and I used datetime and timestamp as item type codes; but I'm thinking of changing those to dt and ts respectively. Any opinions on this?

closes #421

@Morg42 Morg42 merged commit bfa417d into smarthomeNG:develop Apr 1, 2026
4 checks passed
@Morg42 Morg42 deleted the datetime branch April 1, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant