Summary: | Kweather reports wrong sunset/sunrse times for none local places | ||
---|---|---|---|
Product: | [Unmaintained] kicker | Reporter: | J.O. Aho <trizt> |
Component: | general | Assignee: | Aaron J. Seigo <aseigo> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kollix |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
Fixes the time set to 06:00 or 19:00 for sunrise/sunset that occures on another day than today.
Fixes time for sunrise and sunset for remote locations |
Description
J.O. Aho
2006-11-16 13:17:23 UTC
I'd like to apply your patch, but for me the current applet also works ... E.g. I live near Vienna, I have selected Singapore / Changi Airport and I get Sunrise:00:01 Sunset: 12:04 What settings do you use ? Another point: when you submit patches, please use diff -u output, so that we can easily apply your changes with the patch command. And second, coders and other contributors are always welcome! If your time permits, you can help much more and you can even apply for an account so that you can apply changes on your own, if you like. My system uses CET as timezone and target city is Hong Kong, which has a sunraise before midnigh, as Singapore has it's after midnight the bug won't be noticed, the same when the sunset is before midnight. When I posted the bug, I noticed that my old patch didn't work (there been other changes in the kweather/sun.cpp, which resulted that patch didn't find the location where to apply the patch), I'm sorry I didn't take the time to make a new patch for you, I think my old one is still here in the bugzilla somewhere. Created attachment 19023 [details]
Fixes the time set to 06:00 or 19:00 for sunrise/sunset that occures on another day than today.
If you have selected a remote location where the supposed sunrise occures
before midnight, then the time is by default set to 06:00, if you select a
location where sunset occures after midnight, then the time is by default set
to 19:00.
This fix Sun::convertDoubleToLocalTime() function to take care of times that
are outside the normal 24h and converts them back to the 24h clock time.
To test this patch, run in CET timezone and select Hong Kong and Seattle, then
rebuild kweather with patch applied and see the difference.
The patch has been made against the 3.80.2 source code, hopefully this will be
applied before release of KDE4.
SVN commit 616157 by mkoller: BUG: 137448 correct calculation of sunset/sunrise M +6 -2 sun.cpp --- branches/KDE/3.5/kdetoys/kweather/sun.cpp #616156:616157 @@ -206,14 +206,18 @@ // Example: say time is 17.7543 Then hours = 17 and minutes = 0.7543 * 60 = 45.258 int hours = (int)floor(time); int minutes = (int)floor((time - hours) * 60); - + + int localhours = hours + (m_localUTCOffset / 60); + if (localhours < 0) { localhours += 24; } + if (localhours >= 24) { localhours -= 24; } + // Round up or down to nearest second. // Use rint instead of nearbyint because rint is in FreeBSD int seconds = (int)rint( fabs( minutes - ((time - hours) * 60) ) * 60 ); // Try to set the hours, minutes and seconds for the local time. // If this doesn't work, then we will return the invalid time. - result.setHMS( hours + (m_localUTCOffset / 60), minutes + (m_localUTCOffset % 60), seconds ); + result.setHMS( localhours, minutes + (m_localUTCOffset % 60), seconds ); return result; } Not all zones uses full hours, say the remote sunset is 15:35 and there is a timedifference for you that is -5h 30min, then we have that the time will be 20:65, as you can see this isn't a valid time. Even the patch I had uploaded earlier has a bug, it don't consider if to fix the hour correcly in those cases where the minutes are less than 0 or more than 60. On So Dez 24 2006, J.O.Aho wrote:
> Even the patch I had uploaded earlier has a bug, it don't consider if to
> fix the hour correcly in those cases where the minutes are less than 0 or
> more than 60.
So, what is now the correct fix ?
Can you simply send me a new patch, please ?
Created attachment 19029 [details]
Fixes time for sunrise and sunset for remote locations
We now take care of the minutes, as some "timezones" are +/-Xh and 30min
compared to GMT.
Please don't use the old patch, it has a major bug which adjusts the minutes
wrongly.
|