It is currently April 25th, 2024, 4:46 pm

String to Number?

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: String to Number?

Post by jsmorley »

Seems to me that you might want to somehow store the value for "sunset" for the previous day. You would need that after "midnight" to calculate the duration of the "night" for the current, but now previous, day. Everything else you need is in the weather feed from Weather.com. Sunrise and sunset today, sunrise and sunset tomorrow.

I'll have to chew on this. It's getting complicated... ;-)
User avatar
GTI.H
Posts: 75
Joined: December 15th, 2018, 3:35 am

Re: String to Number?

Post by GTI.H »

jsmorley wrote: December 16th, 2018, 3:24 pm Seems to me that you might want to somehow store the value for "sunset" for the previous day. You would need that after "midnight" to calculate the duration of the "night" for the current, but now previous, day. Everything else you need is in the weather feed from Weather.com. Sunrise and sunset today, sunrise and sunset tomorrow.

I'll have to chew on this. It's getting complicated... ;-)
I understand that using tomorrow's data gives us a prediction and not a practiced value.
And consider that the location may change and as in the poles we have permanent days and nights.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: String to Number?

Post by jsmorley »

GTI.H wrote: December 16th, 2018, 3:49 pm I understand that using tomorrow's data gives us a prediction and not a practiced value.
And consider that the location may change and as in the poles we have permanent days and nights.
Well, anything for "tomorrow" is a prediction of course, but I expect they have a pretty good feel for how fast the earth is traveling around the sun, and I imagine the prediction for sunrise tomorrow is reasonably accurate. Technically speaking, "sunset" for today is also a "prediction" until it actually happens.

I have no idea how Weather.com deals with the poles, where "night" lasts longer than 24 hours. I'm not going down that rabbit hole.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: String to Number?

Post by jsmorley »

Seems to me that the lay of the land is something like:

Yesterday
day >> night until midnight
Today
night from midnight >> day >> night until midnight
Tomorrow
night from midnight

To calculate the amount of "night" if it is "before sunrise", say 3am, you would need the value for night until midnight from Yesterday, and add that to night from midnight for Today.

I think everything else is available in the feed, since you can know the values for today and up to 5 days in the future.
User avatar
GTI.H
Posts: 75
Joined: December 15th, 2018, 3:35 am

Re: String to Number?

Post by GTI.H »

jsmorley wrote: December 16th, 2018, 4:01 pm Seems to me that the lay of the land is something like:

Yesterday
day >> night until midnight
Today
night from midnight >> day >> night until midnight
Tomorrow
night from midnight

To calculate the amount of "night" if it is "before sunrise", say 3am, you would need the value for night until midnight from Yesterday, and add that to night from midnight for Today.
In fact I'm talking about hours of sunshine and hours without sunshine and not of Yesterday, Today and Tomorrow.
jsmorley wrote: December 16th, 2018, 4:01 pm I think everything else is available in the feed, since you can know the values for today and up to 5 days in the future.
Yeah, I understood!

Making conceptions and accepting that to calculate (Tomorrow - Today) is equal in precision, prediction and practiced to (Today - Yesterday), this seems the best technique.

Excellent suggestion, I will adopt it.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: String to Number?

Post by jsmorley »

GTI.H wrote: December 16th, 2018, 4:45 pm In fact I'm talking about hours of sunshine and hours without sunshine and not of Yesterday, Today and Tomorrow.
My point there is that if it before sunrise today, the amount of hours without sunshine is equal to the amount of time from sunset until midnight yesterday, added to the time from midnight until sunrise today. If it is after sunrise today, then the amount of hours without sunshine would be the amount of time from sunset to midnight today, added to the time from midnight to sunrise tomorrow.

"Yesterday" is the rub, that is not in the feed.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2605
Joined: March 23rd, 2015, 5:26 pm

Re: String to Number?

Post by SilverAzide »

jsmorley wrote: December 16th, 2018, 3:24 pm Everything else you need is in the weather feed from Weather.com. Sunrise and sunset today, sunrise and sunset tomorrow.
I have not really followed along with this thread, but here is a public service announcement for anyone who cares: weather.com's sunrise/sunset values in the forecast sections are bogus. They are just today's values repeated for each day. The only correct sunrise/sunset values in their feed are the values for today.

So, for the OP, you can easily calc today's day length from the weather.com feed, but for the proper calc of night length, you need tomorrow's sunrise value, and the weather.com value for this is not correct. If you don't mind the length being slightly off, of course you can calculate the night length as being simply 24 hours - day length. If you want day/night lengths and times calculated into the future (i.e., beyond today), the only way to do this properly is with some extremely complicated Lua scripting. There are skins that do this, or that can be somewhat easily modified to do this.
Gadgets Wiki GitHub More Gadgets...
User avatar
GTI.H
Posts: 75
Joined: December 15th, 2018, 3:35 am

Re: String to Number?

Post by GTI.H »

jsmorley wrote: December 16th, 2018, 4:49 pm My point there is that if it before sunrise today, the amount of hours without sunshine is equal to the amount of time from sunset until midnight yesterday, added to the time from midnight until sunrise today. If it is after sunrise on a given day, then the amount of hours without sunshine would be the amount of time from sunset to midnight today, added to the time from midnight to sunrise tomorrow.
Yes, it should be the same.

What I do not understand is why you include midnight? For me it would be transparent on calculations.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: String to Number?

Post by jsmorley »

SilverAzide wrote: December 16th, 2018, 5:03 pm I have not really followed along with this thread, but here is a public service announcement for anyone who cares: weather.com's sunrise/sunset values in the forecast sections are bogus. They are just today's values repeated for each day. The only correct sunrise/sunset values in their feed are the values for today.

So, for the OP, you can easily calc today's day length from the weather.com feed, but for the proper calc of night length, you need tomorrow's sunrise value, and the weather.com value for this is not correct. If you don't mind the length being slightly off, of course you can calculate the night length as being simply 24 hours - day length. If you want day/night lengths and times calculated into the future (i.e., beyond today), the only way to do this properly is with some extremely complicated Lua scripting. There are skins that do this, or that can be somewhat easily modified to do this.
Yeah, I really think that trying to be "accurate" with this using Weather.com as the source is likely more trouble than it is worth.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: String to Number?

Post by jsmorley »

GTI.H wrote: December 16th, 2018, 5:03 pm Yes, it should be the same.

What I do not understand is why you include midnight? For me it would be transparent on calculations.
There is no calculation using Time measure values that will transverse days, unless you use a full date/time as the input string.

If you use 7PM and 3AM in Time measures and calculate the difference, both will be assumed to be "today". It is 16 hours from 7PM today back to 3AM today, but 8 hours from 7PM today forward to 3AM tomorrow.