Community Support

Refresh time into m...
 

[This post is marked as unsolved] Refresh time into map tooltip  

  RSS
daguilera
(@daguilera)
Eminent Member

Hi Pierre, how are you going?

We really appreciate your efforts to put an "updated time" indicator on the map tooltip. But I noticed that the time data inside, it seems like is the "last_refresh" time, instead of what we want: "last_seen" time. I made a minor change into PHP code to get the date using "day-month-year hour:minute" format, but I don't know how to edit the last_refresh time.

Thank you.

David (Redmeteo.cl)

David Aguilera-Riquelme (@davidagriq).
https://redmeteo.cl - an Open Chilean hobbyist weather network

Quote
Posted : 20/04/2019 1:48 am
Pierre Lannoy
(@pierre-lannoy)
Member Admin

Hello David.

Wow, that's a tricky thing you want to do. Let me think about a "simple" method to do this...

If you like Weather Station, please consider to make a review to help make it known. That would be the best way to thank me...

ReplyQuote
Posted : 20/04/2019 3:55 pm
Pierre Lannoy
(@pierre-lannoy)
Member Admin

Hello David, when you say "last seen" time time do you want to speak of "last time the station have been seen" or "last time a specific module have been seen" (and which module)?

If you like Weather Station, please consider to make a review to help make it known. That would be the best way to thank me...

ReplyQuote
Posted : 21/04/2019 12:03 pm
daguilera
(@daguilera)
Eminent Member

Pierre,

I'd like to get the same time that appears into the Stations dashboard (I guess that refers to last time that station had been seen by plugin). 

Best regards

David Aguilera-Riquelme (@davidagriq).
https://redmeteo.cl - an Open Chilean hobbyist weather network

ReplyQuote
Posted : 21/04/2019 7:09 pm
Pierre Lannoy
(@pierre-lannoy)
Member Admin

Hi David!

I've spent many times to think about what you're asking for and it's seems to me not really "reliable" to stay on "last seen" value because this value is null for virtual stations (stations collected from OWM) and I think you have some... Nevermind, if you want to do it, in /wp-content/plugins/live-weather-station/includes/classes/MapBaseHelper.php, line 733, just replace

$date = new \DateTime(date('Y-m-d H:i:s', $timestamp));

by

$date = new \DateTime($station['last_seen']);

but note that it will generate errors for virtual stations (as there's no value for this type of stations).

Note too, that all direct modification in the WS files will be erased when the next update will occur...

 

PS: I move this post from Bug to General Question as it is not a bug...

If you like Weather Station, please consider to make a review to help make it known. That would be the best way to thank me...

ReplyQuote
Posted : 26/04/2019 5:18 pm
daguilera
(@daguilera)
Eminent Member

Thank you, Pierre, for the response.

I used your snippet to build a workaround that works even if I used a virtual weather station.

// $date = new \DateTime(date('Y-m-d H:i:s', $timestamp));
$lastseendate = new \DateTime($station['last_seen']);
$timestampdate = new \DateTime(date('Y-m-d H:i:s', $timestamp));
if ($lastseendate->format('Y') == $timestampdate->format('Y')){
// I compared the Year between the timestamp and last seen
$date = new \DateTime($station['last_seen']);
}
else {
$date = new \DateTime(date('Y-m-d H:i:s', $timestamp));
}

Best regards and again, thank you for the concern.

David

David Aguilera-Riquelme (@davidagriq).
https://redmeteo.cl - an Open Chilean hobbyist weather network

ReplyQuote
Posted : 27/04/2019 4:24 am

To participate, please connect first!