Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.8.0 (build 3090) - 12 August 2020 (please see important announcement regarding releases since 3.5.0)
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of the NOAA report and Snow Index drop-down menus to 2030)

Use this link to Download the Software (Cumulus MX / Cumulus 1 and other related items). Software

Lightning notification

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Mapantz
Posts: 773
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Lightning notification

Post by Mapantz »

Parse error: syntax error, unexpected '--' (T_DEC), expecting ',' or ';' in /home/wareham1/public_html/gw1000.php on line 34

$lightningMinAgo returns -480 as of right now.
Image

User avatar
beteljuice
Posts: 2978
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Lightning notification

Post by beteljuice »

Oops - missing quotes in debug .. :oops: #
Edit: see viewtopic.php?p=145191#p145191 for 'final' code

Code: Select all

$lightningMinAgo = "<#LightningTime format="H,m,s,MM,d,yyyy">";
echo "\n<!-- Cu H,m,s,MM,d,yyyy = ".$lightningMinAgo." -->\n"; // debug
if($lightningMinAgo != "---") $lightningMinAgo = (time() - mktime($lightningMinAgo)) / 60;
echo "\n<!-- Now: ".date(DATE_RFC822)." -->\n<!-- actual mins ago = ".$lightningMinAgo." -->\n"; // debug


<?php if ($lightningMinAgo != "---" && $lightningMinAgo <= 30) { echo '<span class="ligh .....
$lightningMinAgo returns -480 as of right now.
..is meaningless unless you ..
a/ say if that is correct or not
b/ say if the correct logic decision (output) was made :P
Last edited by beteljuice on Thu 13 Aug 2020 12:52 pm, edited 1 time in total.
Image
......................Imagine, what you will KNOW tomorrow !

Mapantz
Posts: 773
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Lightning notification

Post by Mapantz »

view-source:https://warehamwx.co.uk/gw1000.php

Last strike was 4 days ago.

As it's returning -420 now, that would be classed as less than 30.
Image

User avatar
beteljuice
Posts: 2978
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Lightning notification

Post by beteljuice »

<!-- Cu H,m,s,MM,d,yyyy = 8,5,5,07,27,2020 -->

<!-- Now: Sat, 01 Aug 20 01:29:12 +0000 -->
<!-- actual mins ago = -420 -->

... but there must be something wrong with 'time' logic.
27 Jul is much more than 420 mins ago, and -420 shouldn't be "static" - tempus fugit old bean.

I'll look under the bonnet again ..
Image
......................Imagine, what you will KNOW tomorrow !

User avatar
beteljuice
Posts: 2978
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Lightning notification

Post by beteljuice »

Doh ... rookie mistake :lol:

Code: Select all

$lightningMinAgo = "<#LightningTime format="H,m,s,MM,d,yyyy">";

... mktime($lightningMinAgo)) / 60;
Won't work - we can't have quotes around all the vars.
We could define each time var separately, but we'll use strtotime() instead, and slightly modify the definition ;)

Edit: oops - missing ; corrected
Edit: #2 - Corrected to 'final' code

Code: Select all

$lightningMinAgo = "<#LightningTime format="HH:mm:ss"> <#LightningTime format="D">";
if($lightningMinAgo != "---") $lightningMinAgo = (time() - strtotime($lightningMinAgo)) / 60;

<?php if ($lightningMinAgo != "---" && $lightningMinAgo <= 30) { echo '<span class="ligh .....
Hopefully all should now finally be well .....
Last edited by beteljuice on Thu 13 Aug 2020 12:50 pm, edited 2 times in total.
Image
......................Imagine, what you will KNOW tomorrow !

sfws
Posts: 929
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Modified Fine Offset
Operating System: Win. 10 PC
Location: The Marches, UK

Re: Lightning notification

Post by sfws »

beteljuice wrote:
Sat 01 Aug 2020 3:04 am
Won't work - we can't have quotes around all the vars.
We could define each time var separately, but we'll use strtotime() instead, and slightly modify the definition ;)


$lightningMinAgo = "<#LightningTime format="HH:mm:ss D">"
if($lightningMinAgo != "---") $lightningMinAgo = (time() - strtotime($lightningMinAgo)) / 60;

<?php if ($lightningMinAgo != "---" && $lightningMinAgo <= 30) { echo '<span class="ligh .....

Hopefully all should now finally be well .....
Looks like modified code still has quote confusion,
Surely you want

Code: Select all

$lightningMinAgo = '<#LightningTime format="HH:mm:ss D">';

User avatar
beteljuice
Posts: 2978
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Lightning notification

Post by beteljuice »

@swfs
Looks like modified code still has quote confusion,
Not really, as there are two separate processes involved.
By the time PHP gets to see it, only the outer quotes will exist.

However; your query made me see that I'd missed the closing ; from the line :oops:

So thanks :D :clap:
Image
......................Imagine, what you will KNOW tomorrow !

sfws
Posts: 929
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Modified Fine Offset
Operating System: Win. 10 PC
Location: The Marches, UK

Re: Lightning notification

Post by sfws »

beteljuice wrote:
Sat 01 Aug 2020 8:43 pm
By the time PHP gets to see it, only the outer quotes will exist.
I did forget that.
beteljuice wrote:
Sat 01 Aug 2020 8:43 pm
So thanks
Glad it was some use.

Mapantz
Posts: 773
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Lightning notification

Post by Mapantz »

Thank you for the replies!

Code: Select all

$lightningMinAgo = "<#LightningTime format="HH:mm:ss D">";
D doesn't seem to be getting formatted for me..
Image

User avatar
beteljuice
Posts: 2978
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Lightning notification

Post by beteljuice »

Not something I can test unfortunately (not having the software nor a station), but according to the wiki for CuMX
D Displays the date using the format given by the Long Date format. e.g. '22 March 2020' (British Locale)
So what is the 'string' from cumulus ?
Image
......................Imagine, what you will KNOW tomorrow !

Mapantz
Posts: 773
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Lightning notification

Post by Mapantz »

beteljuice wrote:
Sat 01 Aug 2020 10:38 pm
Not something I can test unfortunately (not having the software nor a station), but according to the wiki for CuMX
D Displays the date using the format given by the Long Date format. e.g. '22 March 2020' (British Locale)
So what is the 'string' from cumulus ?
This on it's own works..

Code: Select all

$lightningMinAgo = "<#LightningTime format="D">";
$lightningMinAgo = "27 July 2020";

This returns..

Code: Select all

$lightningMinAgo = "<#LightningTime format="HH:mm:ss D">";
$lightningMinAgo = "08:05:05 D";

Either a bug, or CMX doesn't allow it? :o
Image

User avatar
beteljuice
Posts: 2978
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Lightning notification

Post by beteljuice »

OK - we need to build the string a little bit more ....

Code: Select all

$lightningMinAgo = "<#LightningTime format="HH:mm:ss"> <#LightningTime format="D">";
Image
......................Imagine, what you will KNOW tomorrow !

Mapantz
Posts: 773
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Lightning notification

Post by Mapantz »

beteljuice wrote:
Sat 01 Aug 2020 10:51 pm
OK - we need to build the string a little bit more ....

Code: Select all

$lightningMinAgo = "<#LightningTime format="HH:mm:ss"> <#LightningTime format="D">";
haha yes

I was literally just looking at some of my other files that I use formatting on, and realised that I had to use a duplicate webtag to get another format. Doh!

8146 minutes since the last strike. :)

Thanks for all your help beteljuice.
Image

User avatar
beteljuice
Posts: 2978
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Lightning notification

Post by beteljuice »

I'll wait until you say it works as intended, and edit all my posts to a final solution - I won't delete them just to show the beteljuice is increasingly fallible with the passing of time and changes in software :(
Image
......................Imagine, what you will KNOW tomorrow !

User avatar
mcrossley
Posts: 6771
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Buster Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Lightning notification

Post by mcrossley »

Mapantz wrote:
Sat 01 Aug 2020 10:42 pm

Code: Select all

$lightningMinAgo = "<#LightningTime format="HH:mm:ss D">";
$lightningMinAgo = "08:05:05 D";

Either a bug, or CMX doesn't allow it? :o
The format code "D" is a standard format code for the Long date format. It has to be used on its own and cannot be combined with a custom format string, Microsoft set the rules.
https://docs.microsoft.com/en-us/dotnet ... at-strings
https://docs.microsoft.com/en-us/dotnet ... at-strings

Post Reply