IMPORTANT! The server may go down soon - possibly permanently. Please read the latest post in Announcements and News

I strongly advise all users using my server for their web site to make alternative arrangements.

Outgoing mail is disabled because of the malware on the server. No new forum registrations are currently possible, and mail to the forum administrator will not work.

Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Tag <#time> not working

Discussion and questions about Cumulus weather station software version 1. This section and its subforums are the main place to get help with Cumulus. Anything which is not specific to the type of weather station goes in here; for anything specific to a type of weather station, please use the appropriate subforum. Use the 'website development' section for any questions relating to creating or running a web site for Cumulus data. Discussion of the stations themselves in these sections is fine.
User avatar
ZCH
Posts: 10
Joined: Mon Nov 12, 2012 10:14 am
Weather Station: Davis Vantage Pro
Operating System: Windows 7
Location: Wieringermeer, NL
Contact:

Tag <#time> not working

Postby ZCH » Sat Aug 26, 2017 12:53 pm

http://www.meteo-wieringermeer.nl
From time to time the PC on which Cumulus works stops bij lack of power.
I want to warn vistors for outdated data.
Can anyone help?
I tried:

<script>
var DateTimeNow
var DateTimeUpdate
var DateDif
var Message
var Tmp
</script>
<body style="color: rgb(0, 0, 0); background-color: #838383;">
<!-- WARNING -->
<form name="myform4">
<!--<input type="hidden" name="formvar" value="2017-06-16 12:05">--> <!--This worked fine-->
<input type="hidden" name="formvar" value= <#time format="yyyy-mmmm-d hh:nn"> <!--The problem-->
</form>
<script type="text/javascript">
Tmp = document.myform4.formvar.value;
</script>
<script>
// get Cumulus date of update
alert ("begin"); //check
DateTimeNow = Number(new Date());
alert ("Nu: " + DateTimeNow); //check
DateTimeUpdate = Number(new Date(Tmp));
alert ("Update: " + DateTimeUpdate); //check
DateDif = DateTimeNow - DateTimeUpdate;
alert("Dif: " + DateDif); //check
// Warning. 300000 is 5 mins
if (DateDif > 300000) {
Message = "STORING WEERSTATION\n\nGeen updates ontvangen.\nRapport verouderd, waarnemingen kloppen niet.";
alert(Message);
}
</script>
etc, etc

Elsewhere, the tag works fine:
<caption>Observarions at <#time format="d mmmm yyyy hh:nn"> LT<br>
<b>Caution! </b> Not older than 5 minutes, otherwise failure.
</caption>

User avatar
beteljuice
Posts: 2482
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: Tag <#time> not working

Postby beteljuice » Sat Aug 26, 2017 1:02 pm

Try ....

Code: Select all

<input type="hidden" name="formvar" value= '<#time format="yyyy-mmmm-d hh:nn">'

Your javascript var isn't "quoted" ;)
Image
......................Imagine, what you will KNOW tomorrow !

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

Re: Tag <#time> not working

Postby mcrossley » Sat Aug 26, 2017 5:55 pm

And the <input> tag isn't terminated is it?

User avatar
ZCH
Posts: 10
Joined: Mon Nov 12, 2012 10:14 am
Weather Station: Davis Vantage Pro
Operating System: Windows 7
Location: Wieringermeer, NL
Contact:

Re: Tag <#time> not working

Postby ZCH » Sun Aug 27, 2017 12:31 pm

Thank you very much.
I made a stupid mistake.
I tested next alternatives:
1) <input type="hidden" name="formvar" value="2017-06-16 12:05">
2) <input type="hidden" name="formvar" value= '<#time format="yyyy-mmmm-d hh:nn">' failed
3) <input type="hidden" name="formvar" value= '<#time format="yyyy-mmmm-d hh:nn">'> failed
4) <input type="hidden" name="formvar" value= <#time format="yyyy-mmmm-d hh:nn">> failed
5) <input type="hidden" name="formvar" value= <#time format='yyyy-mmmm-d hh:nn'>> failed
6) <input type="hidden" name="formvar" value= '<#time format="yyyy-mmmm-d hh:nn">'> failed
7) <input type="hidden" name="formvar" value= “<#time format="yyyy-mmmm-d hh:nn">”> failed
8) <input type="hidden" name="formvar" value= “<#time format='yyyy-mmmm-d hh:nn'>”> failed
Only 1) was Ok. But that's not the one I need.
In http://www.meteo-wieringermeer.nl/realtime.txt, the firt 17 characters show upload date and time.
I did not succeed in writing the proper javascript function to get them.

gerard.hageman@planet.nl

User avatar
beteljuice
Posts: 2482
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: Tag <#time> not working

Postby beteljuice » Sun Aug 27, 2017 2:27 pm

Before we start escaping quotes and things - it would be useful if you had a test page link so that we could see what the Cumulus formated date looks like in the input string.

Doesn't have to be a page that 'runs' - just the code after Cumulus has processed it.
Image
......................Imagine, what you will KNOW tomorrow !

sfws
Posts: 450
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Customised mix of Fine Offset
Operating System: Tempermental Win. 10 PC
Location: UK

Re: Tag <#time> not working

Postby sfws » Sun Aug 27, 2017 4:49 pm

I am a little confused, did you want the month as a number or as a word?
If you want the number, maybe you could try '<#update>' as I believe that may output in the ISO date time format you want. It may give a slightly different time because it does not reflect the real-time in the file you quote, but surely it would address
ZCH wrote:I want to warn vistors for outdated data.

The code you could try with month as number is

Code: Select all

<input type="hidden" name="formvar" value="<#update>">

If you want month as word and the space, you could eliminate one set of quotes with

Code: Select all

<input type="hidden" name="formvar" value= '<#time format=yyyy-mmmm-d> <#time format=hh:nn>'>


EDITs - I missed a closing bracket on Cumulus web tag!
BTW - The first post in the thread contains at the start a URL to the page where this is being used!
Last edited by sfws on Mon Aug 28, 2017 3:54 pm, edited 2 times in total.

User avatar
ZCH
Posts: 10
Joined: Mon Nov 12, 2012 10:14 am
Weather Station: Davis Vantage Pro
Operating System: Windows 7
Location: Wieringermeer, NL
Contact:

Re: Tag <#time> not working

Postby ZCH » Sun Aug 27, 2017 8:42 pm

Thank you all for your help.
This proved to be the solution:
<input type="hidden" name="formDate" value= '<#time format="yyyy-m-d hh:nn">'>


Return to “Cumulus 1”

Who is online

Users browsing this forum: No registered users and 4 guests