Finally got around to looking at this and now I'm not so sure it is a bug. Let me ask you a question: given the date you were using, 31 July, what was your expectation for the date a month earlier? Not 31 June; there is no such day.
One could say it should be the last day in June, that is, 30 June. That might make sense, but then it leads to some strange corner cases: What is 30 March minus one month? By this solution, it should be 28 Feb. So then what is 29 March minus one month? Also 28 Feb? And so would 28 March minus a month. So, "one month earlier" for three days in a row leads to the same date? Any ideas? -tk On Tue, Jul 30, 2019 at 5:17 PM Thomas Keffer <[email protected]> wrote: > Thanks, mph. This helps! It seems the problem is on the last day of a long > month that follows a short month. > > I've created issue #436 <https://github.com/weewx/weewx/issues/436> to > track. > > -tk > > On Tue, Jul 30, 2019 at 7:12 PM mph <[email protected]> wrote: > >> I am confirming this reported bug with $month_delta >> >> My template GENERATING bug on Jul 31st: >> >> #set $archive_data = [$day, $span($week_delta=1), $span($month_delta=1), >>> $span($year_delta=1), $week, $month, $year] >>> ... >>> #for $archive in $archive_data >>> <td class="data >>> new_row">$archive.outTemp.max.format(add_label=False)<br/> >>> <span >>> class="timestamp">$archive.outTemp.maxtime.format($dt_format[$archive_data.index($archive)])</span><br/> >>> $archive.outTemp.min.format(add_label=False)<br/> >>> <span >>> class="timestamp">$archive.outTemp.mintime.format($dt_format[$archive_data.index($archive)])</span> >>> </td> >>> #end for >> >> >> >> My workarround SOLVING the issue - using day_delta only: >> >> #set $archive_data = [$day, $span($day_delta=7), $span($day_delta=30), >>> $span($day_delta=365), $week, $month, $year] >>> >> >> >> My log is almost the same as from Pavel Fojt below: >> >> Jul 31 00:50:24 rpi-meteo weewx[25170]: cheetahgenerator: Generate failed >>> with exception '<type 'exceptions.ValueError'>' >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: cheetahgenerator: **** Ignoring >>> template /etc/weewx/skins/Seasons/index.html.tmpl >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: cheetahgenerator: **** Reason: >>> day is out of range for month >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** Traceback (most recent >>> call last): >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** File >>> "/usr/share/weewx/weewx/cheetahgenerator.py", line 332, in generate >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** >>> fd.write(str(compiled_template)) >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** File >>> "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 1005, in >>> __str__ >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** rc = getattr(self, >>> mainMethName)() >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** File >>> "_etc_weewx_skins_Seasons_index_html_tmpl.py", line 218, in respond >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** File >>> "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 1615, in >>> _handleCheetahInclude >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** >>> self._CHEETAH__cheetahIncludes[_includeID].respond(trans) >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** File >>> "_etc_weewx_skins_Seasons_hilo_inc.py", line 94, in respond >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** File >>> "/usr/share/weewx/weewx/tags.py", line 101, in span >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** hour_delta=hour_delta, >>> day_delta=day_delta, week_delta=week_delta, month_delta=month_delta, >>> year_delta=year_delta), >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** File >>> "/usr/share/weewx/weeutil/weeutil.py", line 475, in archiveSpanSpan >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** start_dt = >>> time_dt.replace(year=year, month=month) >>> Jul 31 00:50:24 rpi-meteo weewx[25170]: **** ValueError: day is out of >>> range for month >>> >> >> Thank you >> Pavel >> >> Dne úterý 1. srpna 2017 15:18:35 UTC+2 Thomas Keffer napsal(a): >>> >>> This is probably a bug somewhere. >>> >>> Did you modify the standard index.html.tmpl template? Can you identify >>> what statement in the template is causing the error? >>> >>> -tk >>> >>> On Mon, Jul 31, 2017 at 1:32 AM, Pavel Fojt <[email protected]> wrote: >>> >>>> after midnight (2017-07-30 / 2017-07-31): >>>> >>>> Jul 31 10:30:14 debian1 weewx[143]: cheetahgenerator: Generate failed >>>> with exception '<type 'exceptions.ValueError'>' >>>> Jul 31 10:30:14 debian1 weewx[143]: cheetahgenerator: **** Ignoring >>>> template /etc/weewx/skins/Standard/index.html.tmpl >>>> Jul 31 10:30:14 debian1 weewx[143]: cheetahgenerator: **** Reason: day >>>> is out of range for month >>>> Jul 31 10:30:14 debian1 weewx[143]: **** Traceback (most recent call >>>> last): >>>> Jul 31 10:30:14 debian1 weewx[143]: **** File >>>> "/usr/share/weewx/weewx/cheetahgenerator.py", line 329, in generate >>>> Jul 31 10:30:14 debian1 weewx[143]: **** print >> _file, >>>> compiled_template >>>> Jul 31 10:30:14 debian1 weewx[143]: **** File >>>> "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 1005, in >>>> __str__ >>>> Jul 31 10:30:14 debian1 weewx[143]: **** rc = getattr(self, >>>> mainMethName)() >>>> Jul 31 10:30:14 debian1 weewx[143]: **** File >>>> "_etc_weewx_skins_Standard_index_html_tmpl.py", line 1663, in respond >>>> Jul 31 10:30:14 debian1 weewx[143]: **** File >>>> "_etc_weewx_skins_Standard_index_html_tmpl.py", line 707, in >>>> __errorCatcher92 >>>> Jul 31 10:30:14 debian1 weewx[143]: **** File "<string>", line 1, in >>>> <module> >>>> Jul 31 10:30:14 debian1 weewx[143]: **** File >>>> "/usr/share/weewx/weewx/tags.py", line 101, in span >>>> Jul 31 10:30:14 debian1 weewx[143]: **** hour_delta=hour_delta, >>>> day_delta=day_delta, week_delta=week_delta, month_delta=month_delta, >>>> year_delta=year_delta), >>>> Jul 31 10:30:14 debian1 weewx[143]: **** File >>>> "/usr/share/weewx/weeutil/weeutil.py", line 532, in archiveSpanSpan >>>> Jul 31 10:30:14 debian1 weewx[143]: **** start_dt = >>>> time_dt.replace(year=year, month=month) >>>> Jul 31 10:30:14 debian1 weewx[143]: **** ValueError: day is out of >>>> range for month >>>> >>>> weewx version v3.7.1 >>>> >>>> problem with 31days for July? >>>> >>>> thanks >>>> >>>> Pavel >>>> >>>> -- >>>> 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]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >> -- >> 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/fe6603a7-00f7-4d6e-8537-ccebca757891%40googlegroups.com >> <https://groups.google.com/d/msgid/weewx-user/fe6603a7-00f7-4d6e-8537-ccebca757891%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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/CAPq0zECbb78KKB6fuJFFEdL1WHHahyUrLuU8ZVwEO-gAjTL5dw%40mail.gmail.com.
