Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 114980 - Kweather (2.1.0) misscalculates Sunrise and Sunset
Summary: Kweather (2.1.0) misscalculates Sunrise and Sunset
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] KDE (show other bugs)
Hardware: All Linux
: High normal
Assignee: Gentoo KDE team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-09 05:42 UTC by J.O. Aho
Modified: 2007-02-28 11:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
kweather_time.patch (kweather_time.patch,970 bytes, patch)
2005-12-09 05:47 UTC, J.O. Aho
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description J.O. Aho 2005-12-09 05:42:18 UTC
When Kweather calculates sunrise and sunset, it don't manage to see if the event
happens the prvious day or next day, which results in that you get a false time
(event day before -> 06:00, even next day -> 19:00).

Reproducible: Always
Steps to Reproduce:
1. emerge kde-base/kweather (if you use kde-meta)
2. Add kweather applet to your (kde) panel
3. Configure kweather to show a location 7+ hours away from you
4. View weahter report

Actual Results:  
User in Europe (CET) who selects Seattle

 Sunrise: 16:45
 Sunset:  19:00

Expected Results:  
User in Europe (CET) who selects Seattle

 Sunrise: 16:45
 Sunset:  01:18

This affects all releases of KDE with KWeather 2.1.0, as far as I know it's at
least all versions between 3.2 and 3.5.
Comment 1 J.O. Aho 2005-12-09 05:47:13 UTC
Created attachment 74376 [details, diff]
kweather_time.patch

This adjusts the hour value to a correct value if the timedifference between
timezones makes that an event happens the previous day or the next day.

For values <0 we add 24h, for values >24 we remove 24h, this makes the time
always to be valid.
Comment 2 J.O. Aho 2005-12-09 08:59:29 UTC
Comment on attachment 74376 [details, diff]
kweather_time.patch

--- kweather/sun.cpp 2005-12-09 14:13:40.000000000 +0100
+++ kweather/sun.cpp 2005-12-09 14:16:12.000000000 +0100
@@ -206,6 +206,9 @@
	// 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
@@ -213,7 +216,7 @@

	// 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;
 }
Comment 3 Caleb Tennis (RETIRED) gentoo-dev 2005-12-15 06:13:06 UTC
Can you notify the kweather devs so they can fix it in their sources? 
 
http://kweather.sourceforge.net/ 
Comment 4 Dominik Stadler (RETIRED) gentoo-dev 2006-02-04 03:11:16 UTC
Is this problem still present in the version of KWeather that comes with KDE 3.5.x?
Comment 5 Caleb Tennis (RETIRED) gentoo-dev 2006-02-28 16:26:14 UTC
no response - this kind of thing need to be filed at bugs.kde.org
Comment 6 J.O. Aho 2007-02-28 11:28:00 UTC
The bug has been listed in the KDE bugzilla since KDE3.1 if I don't remember it wrong, there been a couple of suggested patches too.

This has now been fixed in the KDE source, at least in 3.80.

The KDE 3.5.5 still uses the unfixed source, according a post in 165267, the fixed source should be used in KDE 3.5.6, as it's still masked I haven't yet checked it.

Sorry for the long delay, but as all mail out of gentoo.org is filtered away as junkmail, I had to use an e-mail address that I don't use and therefore won't get your messages.