System Variables timestamp **solved**

All about the standard Meteobridge devices based on mobile routers from TP-Link, D-Link, ASUS

Moderator: Mattk

Post Reply
satellitedan
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: Mon Mar 28, 2016 6:23 am

System Variables timestamp **solved**

Post by satellitedan » Mon Mar 28, 2016 7:00 am

First post! I've been using meteobridge for about a week or so and every day I'm learning something new.

There are a few things I could not find the answer to as far as making an email/twitter script.

Is there a way to remove a leading zero from a timestamp? For example, I would like 08:20am to show up as 8:20am. I've figured out the am/pm thing but not how to remove the leading zero.

The sunrise/sunset & moonrise/moonset timestamps are in 24hr time. Is there a way to convert it to 12hr time?

I've tried [mbsystem-sunset=apm] but that only returns the 24hr time (19:40) instead of 12hr time (7:40).

The actual time is correct, I just can't figure out how to make it display 12hr time.

Thanks!

User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 5829
Joined: Mon Oct 01, 2007 10:51 pm

Re: System Variables timestamp

Post by admin » Mon Mar 28, 2016 12:27 pm

"apm" converter is not defined for sunset/sunrise. I will add this with one of the next updates.

Regarding the leading zero, in which situation are you looking to get rid of it?

satellitedan
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: Mon Mar 28, 2016 6:23 am

Re: System Variables timestamp

Post by satellitedan » Mon Mar 28, 2016 12:45 pm

Thank you!

I have a timestamp on a few things, like the min/max temperature. It returns with the leading zero (see attached)
IMG_20160328_064020.jpg
IMG_20160328_064020.jpg (238.27 KiB) Viewed 2939 times
Sorry for the large size, I uploaded it from my phone.

User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 5829
Joined: Mon Oct 01, 2007 10:51 pm

Re: System Variables timestamp

Post by admin » Mon Mar 28, 2016 5:29 pm

You can select the to be skipped character and make use of an #if# #then# #else# #fi# clause to skip the leading char if it is a zero.

When you post one of your timestamp variable definitions, I can show as an example how to apply this.

satellitedan
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: Mon Mar 28, 2016 6:23 am

Re: System Variables timestamp

Post by satellitedan » Mon Mar 28, 2016 11:34 pm

I appreciate the help. Here is the code for the first line in the table image I posted earlier:

<tr><td>Outdoor Temp</td><td>[th0temp-act=F.1:--]°F</td><td>[th0temp-dmin=F.1:--]°F <font size='1'>[th0temp-dmintime=apm.ij:--]:[th0temp-dmintime.kl][th0temp-dmintime=apm.op]<font size='3'></td><td>[th0temp-dmax=F.1:--]°F <font size='1'>[th0temp-dmaxtime=apm.ij]:[th0temp-dmaxtime.kl][th0temp-dmaxtime=apm.op]<font size='3'></td></tr>

satellitedan
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: Mon Mar 28, 2016 6:23 am

Re: System Variables timestamp

Post by satellitedan » Tue Mar 29, 2016 3:05 am

admin wrote:"apm" converter is not defined for sunset/sunrise. I will add this with one of the next updates.
Thank you for adding this!

satellitedan
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: Mon Mar 28, 2016 6:23 am

Re: System Variables timestamp

Post by satellitedan » Wed Mar 30, 2016 5:29 pm

I just realized that am & pm do not show up for moonrise/moonset. It is fine for sunrise/sunset.

Here is the code I have for that:
Sunrise [mbsystem-sunrise=apm] - Sunset [mbsystem-sunset=apm]<br>Moonrise [mbsystem-moonrise=apm:NoData] - Moonset [mbsystem-moonset=apm:NoData]

This is how it shows up:
Clipboard01.png
Clipboard01.png (21.75 KiB) Viewed 2885 times

User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 5829
Joined: Mon Oct 01, 2007 10:51 pm

Re: System Variables timestamp

Post by admin » Sun Apr 03, 2016 1:51 pm

Latest update should that have fixed. AM/PM display option also surpresses leading zeros in the hours field.

satellitedan
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: Mon Mar 28, 2016 6:23 am

Re: System Variables timestamp

Post by satellitedan » Wed Apr 20, 2016 11:42 am

admin wrote:Latest update should that have fixed. AM/PM display option also surpresses leading zeros in the hours field.
Much appreciated!

SANdood
Senior Boarder
Senior Boarder
Posts: 54
Joined: Wed Jan 28, 2015 1:36 pm

Re: System Variables timestamp **solved**

Post by SANdood » Wed Jun 27, 2018 10:54 pm

In version 3.7, =apm no longer has any affect on the output for moonrise/moonset (=utc does, though).

My code (is creating a JSON Map):

Code: Select all

/cgi-bin/template.cgi?template={"moonrise":"[mbsystem-moonrise=apm:null]"}&contenttype=application/json;charset=utf-8

User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 5829
Joined: Mon Oct 01, 2007 10:51 pm

Re: System Variables timestamp **solved**

Post by admin » Sat Jun 30, 2018 9:04 am

Are you sure that works as you expected in 3.6? Please give it a try. I am no aware that I did changes there, so please confirm that it is a 3.7 bug before I start investing time again on this.

n8911
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: Tue Nov 20, 2018 2:22 pm

Re: System Variables timestamp

Post by n8911 » Sun Apr 21, 2019 11:56 am

admin wrote:
Mon Mar 28, 2016 5:29 pm
You can select the to be skipped character and make use of an #if# #then# #else# #fi# clause to skip the leading char if it is a zero.

When you post one of your timestamp variable definitions, I can show as an example how to apply this.

I too am looking to get rid of a leading zero in a string. I am trying to figure out how to do this but do not see an example. Anyway you can help me out?

Post Reply