Gary, thanks for this code snippet! It would satisfy my needs, but I can't get it to run and didn't see the problem as my skills are limited regarding cheetha and python. You lines raises this error:
*Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: Generate failed with exception '<class 'Cheetah.Parser.ParseError'>'Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Ignoring template /etc/weewx/skins/Responsive/index.html.tmplSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Reason: #012#012Invalid Syntax#012Line 322, column 28 in file /etc/weewx/skins/Responsive/index.html.tmpl#012#012Line|Cheetah Code#012----|-------------------------------------------------------------#012319 |#012320 |## end windrun#012321 |#import time#012322 |#set $utc = $time.strftime(‘%d %B %Y %H:%M:%S’, $time.gmtime($current.dateTime.raw))#012 ^#012323 |#012324 | <body>#012325 | <div class="container-fluid">Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Traceback (most recent call last):Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/share/weewx/weewx/cheetahgenerator.py", line 318, in generateSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** compiled_template = Cheetah.Template.Template(Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1337, in __init__Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** self._compile(source, file, compilerSettings=compilerSettings)Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1634, in _compileSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** templateClass = self.compile(source, file,Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 775, in compileSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** compiler.compile()Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Compiler.py", line 1802, in compileSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** self._parser.parse()Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 1552, in parseSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** self.eatDirective()Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 1680, in eatDirectiveSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** directiveParser()Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 2269, in eatSetSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** RVALUE = self.getExpression()Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 1261, in getExpressionSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** return ''.join(self.getExpressionParts(Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 1220, in getExpressionPartsSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** expr = self.getCheetahVar()Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 903, in getCheetahVarSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** return self.getCheetahVarBody(plain=plain)Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 907, in getCheetahVarBodySep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** return self._compiler.genCheetahVar(self.getCheetahVarNameChunks(),Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 955, in getCheetahVarNameChunksSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** rest = self.getCallArgString()Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 1041, in getCallArgStringSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** token = self.getPyToken()Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** File "/usr/lib/python3/dist-packages/Cheetah/Parser.py", line 606, in getPyTokenSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** raise ParseError(self)Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Cheetah.Parser.ParseError: Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Invalid SyntaxSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Line 322, column 28 in file /etc/weewx/skins/Responsive/index.html.tmplSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** Line|Cheetah CodeSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** ----|-------------------------------------------------------------Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** 319 |Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** 320 |## end windrunSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** 321 |#import timeSep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** 322 |#set $utc = $time.strftime(‘%d %B %Y %H:%M:%S’, $time.gmtime($current.dateTime.raw))Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** ^Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** 323 |Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** 324 | <body>Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** 325 | <div class="container-fluid">Sep 19 08:11:18 weewx weewx[563] ERROR weewx.cheetahgenerator: **** * The formatting seems somehow not to work I think: *$time.strftime(‘%d %B %Y %H:%M:%S’...* If I place this *#set $utc = $time.gmtime($current.dateTime.raw) * in my code I get this output on my html site for $utc: time.struct_time(tm_year=2021, tm_mon=9, tm_mday=19, tm_hour=6, tm_min=19, tm_sec=0, tm_wday=6, tm_yday=262, tm_isdst=0) Any hint or idea what could be wrong? Regards, Christian gjr80 schrieb am Samstag, 18. September 2021 um 11:02:54 UTC+2: > There is no tag to display the current dateTime value in UTC/GMT. You will > need to manually construct a tag with a little in-template python code. A > simple approach is to add something like the following (untested) to your > template: > > #import time > #set $utc = $time.strftime(‘%d %B %Y %H:%M:%S’, > $time.gmtime($current.dateTime.raw)) > > should allow you to use the tag $utc later in your template to display the > current dateTime as UTC. The formatting is controlled by the format string > in the $time.gmtime() call. The available format codes can be found here > <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes> > . > > There are other more complex approaches depending on your need. > > Gary > > On Saturday, 18 September 2021 at 18:18:56 UTC+10 [email protected] > wrote: > >> Hi, >> I set my machine to local time, so $current.dateTime gives me 18.09.2021 >> 10:13. >> Is there a tag to get the UTC time (like $current.dateTime .UTC) ? >> I want to display both times as I added some sat pictures which includes >> the UTC time on the picture. To get a better overview I want the UTC time >> additional in my skin printed out.. >> >> Thanks in advance, >> >> Christian >> > -- 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/18accf1f-3607-4839-b584-486dfa760a84n%40googlegroups.com.
