It is currently April 24th, 2024, 5:20 am

Getting time differences with RegExp / Timestamp

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Getting time differences with RegExp / Timestamp

Post by jsmorley »

Mordasius wrote: November 4th, 2018, 12:16 pm Looks promising but a fair amount of scraping would be needed. Something to play with though...
Yeah, the user inputs a city and you display say up to the first 10 from that list. They select one, and you use the link associated with it to get to whatever page in timeanddate.com you want. There are several that have the current timezone offset for that location. Then you parse that to get the values you need. It's not much different than the approach with weather.com.
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Getting time differences with RegExp / Timestamp

Post by Mordasius »

jsmorley wrote: November 4th, 2018, 12:22 pm It's not much different than the approach with weather.com.
No it's not. Once you have the href="/worldclock/@7814354" bit it's fairly easy to move onto the page with the (correct) TimeZone along with the latitude and longitude.

I guess the grass can wait for a few days and I can still see out the windows so why would they need cleaning?

Thanks J.S.
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Getting time differences with RegExp / Timestamp

Post by Mordasius »

Here is what I have for the Sun/Moon settings skin for my ShapelyChameleon collection.
settings.jpg
settings.jpg
It uses TimeAndDate.com as suggested by J.S.Morley. Only eight options from the search function but you can always edit the values of location, latitude, longitude and TimeZone manually if your location doesn't show up in the search listing.

Please note that the time zone for places like New Delhi is returned at +5.30 (five hours : thirty minutes) which you need to change to 5.5 if you use the timezone in a lua script. You can just drop the following function in the lua script to get the correct results for sunrise. sunset, etc.

Code: Select all

function fixTimeZone(num)
		local hrs = math.floor(num)
		return hrs + ( ((num - hrs ) *100 )/60 )
end
You do not have the required permissions to view the files attached to this post.