PR #778 <https://github.com/weewx/weewx/pull/778>
gjr80 schrieb am Mittwoch, 29. Juni 2022 um 06:25:32 UTC+2: > The other alternative is to use a SLE, same methodology (ie do the > calculations and return a ValueHelper) applies but the code will be > longer though arguably easier to read/maintain. For one-off jobs the > in-line template will probably be the easiest solution. For large templates > or repeated use the SLE starts to come into it's own. > > I'm not aware of anywhere this is documented as such. > > Gary > > On Monday, 27 June 2022 at 00:51:28 UTC+10 [email protected] wrote: > >> You can calculate values using the #set directive in Cheetah. I wondered >> how to format those values for output, and after some testing I found the >> following solution. As an example the daylight duration is calculated from >> sunrise and sunset times: >> >> #from weewx.units import ValueTuple,ValueHelper >> #set $rising=$almanac.sun.rise.raw >> #set $setting=$almanac.sun.set.raw >> #set $daylight=$setting-$rising >> #set >> $daylight_vh=ValueHelper(ValueTuple($daylight,'second','group_deltatime'),formatter=$station.formatter) >> >> >> $daylight_vh.format("%(hour)d%(hour_label) %(minute)d%(minute_label)s >> %(second)d%(second_label)s",""). >> >> Is there a better solution? >> >> In skins I see this calculated "by hand" in a series of #set statements. >> >> Is it explained somewhere in the manuals? >> >> -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/bb007b1b-8484-4d7b-addf-c377319f9a8cn%40googlegroups.com.
