Page 1 of 1

Help with web tag date/time format

Posted: Thu 29 May 2014 9:47 pm
by mcrossley
I may be missing something here, but how can you incorporate a quotation mark - single or double - in a web tag date/time format string?

I have tried...
<#tag format="dd mmm yyyy' <"quoted_string"> 'hh:nn">
but the parser stops at the second double quote even though it is inside single quotes: "12 Jan 2014 <"

I tried double single quotes...
<#tag format="dd mmm yyyy' <''quoted_string''> 'hh:nn">
But the ignores the singles completely (obvious really, they simple close and re-open the 'string'): "12 Jan 2014 <quoted_string> 12:34"

I tried a backslash escape...
<#tag format="dd mmm yyyy' <\"quoted_string\"> 'hh:nn">
That drives the parser mad, I get all sorts of garbage out.

I know I can do this by using the tag twice, but is there a way of doing it one hit?

Re: Help with web tag date/time format

Posted: Thu 29 May 2014 10:54 pm
by beteljuice
Why do you need < and > ?

<#tag format="dd mmm yyyy 'unquoted_string' hh:nn">

Re: Help with web tag date/time format

Posted: Fri 30 May 2014 7:03 am
by steve
The normal way to put quotes in a string in Delphi is to repeat the quote symbol to escape it, but because web tags are a mix of HTML and Delphi string processing, I don't think this will work. Can you not just use " and &apos; as you would usually in HTML in situations like this?

Re: Help with web tag date/time format

Posted: Fri 30 May 2014 9:32 am
by mcrossley
Hmm, Steve the " method won't work. Betelejuice, I was trying to simply the format string... What I was trying to do was embed some HTML into the format string, ending up with a string like this...

'01 Jan 1900<span class="class_name"> at 01:23</span>'

You can probably see how that could be used.

Re: Help with web tag date/time format

Posted: Fri 30 May 2014 9:44 am
by steve
mcrossley wrote:Hmm, Steve the " method won't work.
Yes, I see the problem if what you're trying to create is HTML. I think that there are too many language/protocol/conversion levels in the way for 'raw' quote characters to get handled properly inside the format parameter of a web tag.

The new version of Cumulus has to have web tag 'escaping' done differently, which is going to require people to change their format parameters, unfortunately, but it does mean that what you're trying to do here will work.

Re: Help with web tag date/time format

Posted: Fri 30 May 2014 10:24 am
by beteljuice
If 'escaped' coding won't work, you'll have to format the <#webtag> twice ...

<#tag format="dd mmm yyyy"> <span class="class_name"><#tag format="hh:nn"></span>

Re: Help with web tag date/time format

Posted: Fri 30 May 2014 10:50 am
by mcrossley
Opps, forgot to press Submit on this, so yes beteljuice this is what I have done...

Ah well, I guess I'll have to use a construct like...

'<#ByMonthTempHT mon=1 format="dd'&nbsp;'mmm'&nbsp;'yyyy"><span class="class_name"><#ByMonthTempHT mon=1 format=" 'at' hh:nn"></span>'

Only 216 times for the monthly records!

Re: Help with web tag date/time format

Posted: Fri 30 May 2014 11:24 am
by beteljuice
You shouldn't need '&nbsp;' - a small saving ....

Re: Help with web tag date/time format

Posted: Fri 30 May 2014 11:35 am
by mcrossley
You're right, I needed it before to stop the line splitting mid way through the date, now it is shorter on mobile devices it should not break anyway.

Got the monthly and all time records pages displaying better on my phone now, no line wrapping, but you lose the time and full spellings of Maximum/Minimum -> Max Min. Works for me

Re: Help with web tag date/time format

Posted: Tue 15 Jul 2014 3:41 am
by sfws
Mark
You've done your 216 times typing now, but I did not pick this up when you posted the question.
It occurs to me that you did not need to type in

Code: Select all

 class="not-mobile"
multiple times, as you could simply have used in CSS the selector

Code: Select all

td span{     }
with any required definition as per that class. Or you could define a class at table level and prefix the selector with the class. The point is that Cumulus permits a HTML tag within the format and that can be used as the basis of changing the look for that part of the format.

I use the following

Code: Select all

<td><#apptempH> <#tempunit> <#TapptempH format="'at 'h:nn'&nbsp;'am/pm '<small>on' d/m/yyyy'</small>'"></td>
construct on one of my (not online) web pages, so the date is shorter as my chosen format for the time is longer. (My reason for using that time format is that some cells like those for total rain have the rollover time web tag in them and as that outputs '9am' for me I wanted all times to be consistent). If I was putting my web page online, I could redefine that small within td to hide it for mobiles.

Re: Help with web tag date/time format

Posted: Fri 25 Jul 2014 8:13 pm
by mcrossley
Thanks, yes that would be a better way of doing it, I may revisit this when I have time, but for now the power of regex and Sublime edit has got me going.