Skip to content

Commit

Permalink
Merge pull request #11 from teeks99/iso-time
Browse files Browse the repository at this point in the history
Test of time formatted in ISO standard
  • Loading branch information
teeks99 authored Jan 1, 2024
2 parents 10be3fc + c3c644a commit f0ec36e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Upcoming
--------

* Using ISO8601 for the default timestamp format. For existing functionality change the `timestamp_fmt` option to
`human`.

1.1
---
Expand Down
4 changes: 4 additions & 0 deletions skins/JSON/current_minimal.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
},
"generation":
{
#if $Extras.timestamp_fmt is "human"
"time": "$current.dateTime.format("%a, %d %b %Y %H:%M:%S %Z")",
#else
"time": "$current.dateTime.format("%Y-%m-%dT%H:%M:%S%z")",
#end if
"generator": "weewx $station.version"
},
"current":
Expand Down
7 changes: 7 additions & 0 deletions skins/JSON/skin.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[Extras]
# Format of the timestamp, defaults to ISO, also supports `human`
# Defined by python's datetime module https://docs.python.org/3/library/datetime.html
# iso - %Y-%m-%dT%H:%M:%S%z
# human - %a, %d %b %Y %H:%M:%S %Z
timestamp_fmt = iso

[CheetahGenerator]
# This section is used by the generator CheetahGenerator, and specifies
# which files are to be generated from which template.
Expand Down
4 changes: 4 additions & 0 deletions skins/JSON/weewx.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
},
"generation":
{
#if $Extras.timestamp_fmt is "human"
"time": "$current.dateTime.format("%a, %d %b %Y %H:%M:%S %Z")",
#else
"time": "$current.dateTime.format("%Y-%m-%dT%H:%M:%S%z")",
#end if
"generator": "weewx $station.version"
},
"current":
Expand Down

0 comments on commit f0ec36e

Please sign in to comment.