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/40be4e05-d389-441e-8cc4-39ffc1c93d2dn%40googlegroups.com.
