Bug 74999 - Night Weather Icons show during Day/Day during Night
Summary: Night Weather Icons show during Day/Day during Night
Status: RESOLVED FIXED
Alias: None
Product: kweather-kde3
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: John Ratke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-11 20:50 UTC by Unknown
Modified: 2004-08-26 20:44 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Kweather report screenshot showing time and icon errors (42.39 KB, image/png)
2004-02-16 11:25 UTC, Unknown
Details
KWeather report snapshot update after CVS update 20040220 (41.63 KB, image/png)
2004-02-20 12:38 UTC, Unknown
Details
Patch file for sun.cpp (1.34 KB, patch)
2004-02-21 12:49 UTC, Unknown
Details
Snapshot showing correct sunrise and sunset times per patch (47.31 KB, image/png)
2004-02-21 12:50 UTC, Unknown
Details
patch file for modules including Civil Twilight mods (8.65 KB, patch)
2004-02-22 13:51 UTC, Unknown
Details
snapshot showing result of civil twilight mods (54.69 KB, image/png)
2004-02-22 13:54 UTC, Unknown
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Unknown 2004-02-11 20:50:54 UTC
Version:           2.1.0 (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc version 3.2.3
OS:          Linux (i686) release 2.6.2

At 1400 ET (1900 UTC) weather icons go from day to night. At 0400 ET (0900 UTC) weather icons show daytime icons.

Looking at the output, weather time is UTC, but is not being converted prior to retrieving proper icon. Time shown in weather report is local time.

From my last weather update (1353 ET local time)
kweatherservice: Searching for job...
kweatherservice: Reading: /tmp/kde-peter/KWeatherServicefNdDvb-weather
kweatherservice: Parse:  2004/02/11 18:53 KTTN 111853Z 29011KT 10SM CLR 02/M09 A3012 RMK AO2 SLP196 T00221089
kweatherservice: Processing data:  2004/02/11 18:53 KTTN 111853Z 29011KT 10SM CLR 02/M09 A3012 RMK AO2 SLP196 T00221089
kweatherservice: Processing Token: 2004/02/11
kweatherservice: Date: 2004/02/11-2004/02/11
kweatherservice: Processing Token: 18:53
kweatherservice: Time: 18:53-18:53
kweatherservice: Processing Token: 111853Z
kweatherservice: Processing Token: 29011KT
kweatherservice: Wind: 29011KT-290-11--KT
kweatherservice: Processing Token: 10SM
kweatherservice: Visibility: 10SM-10
kweatherservice: Processing Token: CLR
kweatherservice: Cover: CLR-CLR-
kweatherservice: *** Clouds: 0
kweatherservice: Processing Token: 02/M09
kweatherservice: Temp: 02/M09--02-M-09
kweatherservice: Processing Token: A3012
kweatherservice: Pressure: A3012-A-3012
kweatherservice: Wind Chill: 27.3106
kweatherservice: Clouds: 0, Icon: sunny_night
kweatherservice: Sending update for kttn
kweather: refresh kttn
kweather: Show weather
Comment 1 Unknown 2004-02-12 00:01:47 UTC
Sunrise/Sunset times are UTC AND incorrect also, for today 2/11/04, according to kweather, sunrise = 12:39 AM, sunset = 1:38PM.  BTW, sunrise and sunset should be one word each, not sun rise or sun set. However, the correct local times are 0658 ET and 1729 ET, so I am not sure where this data is coming from.

http://aa.usno.navy.mil/data/docs/RS_OneDay.html

U.S. Naval Observatory
Astronomical Applications Department

Sun and Moon Data for One Day

The following information is provided for Trenton, Mercer County, New Jersey (longitude W74.8, latitude N40.2):

        Wednesday
        11 February 2004      Eastern Standard Time          

                         SUN
        Begin civil twilight       6:30 a.m.                 
        Sunrise                    6:58 a.m.                 
        Sun transit               12:13 p.m.                 
        Sunset                     5:29 p.m.                 
        End civil twilight         5:57 p.m.                 

                         MOON
        Moonrise                  10:17 p.m. on preceding day
        Moon transit               4:07 a.m.                 
        Moonset                    9:46 a.m.                 
        Moonrise                  11:28 p.m.                 
        Moonset                   10:14 a.m. on following day

 
Comment 2 Unknown 2004-02-16 11:23:50 UTC
From 2/16/04 CVS update. Note, UTC times still being used as local, and sunrise and sunset times still off. Screenshot attached.

kweatherservice: Reading: /tmp/kde-peter/KWeatherServiceI2WeAa-weather
kweatherservice: Parse:  2004/02/16 08:53 KTTN 160853Z AUTO 36006KT 10SM CLR M11/M21 A3039 RMK AO2 SLP288 T11061206 53006
kweatherservice: Processing data:  2004/02/16 08:53 KTTN 160853Z AUTO 36006KT 10SM CLR M11/M21 A3039 RMK AO2 SLP288 T11061206 53006
kweatherservice: Processing Token: 2004/02/16
kweatherservice: Date: 2004/02/16-2004/02/16
kweatherservice: Processing Token: 08:53
kweatherservice: Time: 08:53-08:53
kweatherservice: Processing Token: 160853Z
kweatherservice: Processing Token: AUTO
kweatherservice: Current: AUTO--AUTO
kweatherservice: Processing Token: 36006KT
kweatherservice: Wind: 36006KT-360-06--KT
kweatherservice: Processing Token: 10SM
kweatherservice: Visibility: 10SM-10
kweatherservice: Processing Token: CLR
kweatherservice: Cover: CLR-CLR-
kweatherservice: *** Clouds: 0
kweatherservice: Processing Token: M11/M21
kweatherservice: Temp: M11/M21-M-11-M-21
kweatherservice: Processing Token: A3039
kweatherservice: Pressure: A3039-A-3039
kweatherservice: Wind Chill: 2.65035
kweatherservice: Clouds: 0, Icon: sunny
kweatherservice: Sending update for kttn
kweatherservice: Searching for job...
kweather: refresh kttn
kweather: Show weather
kweatherservice: Returning kttn
kweatherservice: Get the current weather icon..
Comment 3 Unknown 2004-02-16 11:25:47 UTC
Created attachment 4720 [details]
Kweather report screenshot showing time and icon errors

Just a quick snapshot to go along with the log output also provided.
Comment 4 John Ratke 2004-02-20 04:02:06 UTC
Peter, what are the contents of your /etc/timezone?   Is your system clock set to UTC or localtime?

(Debian has a file /etc/defaults/rcS that controls which way the os thinks the system clock is set, and also a tzsetup utility).

I have added some debugging messages to weatherlib.cpp, so if you would update to a new CVS version, we should see a bit more information like the following line:
kweatherservice: current, rise, set, offset: 21:36:47 06:19:58 18:06:11 -300

offset, the last number, should be the offset in minutes from UTC to the local time.

Could you tell us what your values are from that?

Thanks
Comment 5 Unknown 2004-02-20 12:36:11 UTC
Hi John, here is the info you requested. In addition, I loaded a second screenshot should you require it. Seems to me that KDE has a hard time finding the time offset in my system and that's causing you trouble. Interesting though is that the local time is displayed correctly on the report output.

Regards,

time set to localtime during boot (rs.S), timezone to US/Eastern
peter@peterhq:~$ date +%z
-0500
peter@peterhq:~$ date
Fri Feb 20 06:28:29 EST 2004

Updated to cvs, and captured the following from terminal during kweather:
kweather: Showing out the report
kweatherservice: Get the current weather icon..
kweatherservice: Returning kttn
kweatherservice: rise time: 00:49:21
kweatherservice: set time: 13:38:15

Note: there is NO OFFSET shown, which could be the problem in my case. Either, the timezone storage mechanism on my system is non standard (Slackware 9.1, BSD-like) or KDE has a hard time finding or converting it? Clock works OK.

Here is the parsing dialog:
kweatherservice: Searching for job...
kweatherservice: Reading: /tmp/kde-peter/KWeatherServiceiCyhib-weather
kweatherservice: Parse:  2004/02/20 09:53 KTTN 200953Z AUTO 32003KT 8SM CLR M03/M04 A3001 RMK AO2 SLP157 T10281044
kweatherservice: Processing data:  2004/02/20 09:53 KTTN 200953Z AUTO 32003KT 8SM CLR M03/M04 A3001 RMK AO2 SLP157 T10281044
kweatherservice: Processing Token: 2004/02/20
kweatherservice: Date: 2004/02/20-2004/02/20
kweatherservice: Processing Token: 09:53
kweatherservice: Time: 09:53-09:53
kweatherservice: Processing Token: 200953Z
kweatherservice: Processing Token: AUTO
kweatherservice: Current: AUTO--AUTO
kweatherservice: Processing Token: 32003KT
kweatherservice: Wind: 32003KT-320-03--KT
kweatherservice: Processing Token: 8SM
kweatherservice: Visibility: 8SM-8
kweatherservice: Processing Token: CLR
kweatherservice: Cover: CLR-CLR-
kweatherservice: *** Clouds: 0
kweatherservice: Processing Token: M03/M04
kweatherservice: Temp: M03/M04-M-03-M-04
kweatherservice: Processing Token: A3001
kweatherservice: Pressure: A3001-A-3001
kweatherservice: Wind Chill: 23.2085
kweatherservice: Clouds: 0, Icon: sunny
kweatherservice: Sending update for kttn
Comment 6 Unknown 2004-02-20 12:38:21 UTC
Created attachment 4797 [details]
KWeather report snapshot update after CVS update 20040220
Comment 7 John Ratke 2004-02-21 07:27:41 UTC
You would only see an offset on an output line similar to the one from my previous post.  Looks like the code that would print that output is not called very often.

I made an attempt to change the way the sun code converts from UTC time to local time.  I did this on version 1.7 of sun.cpp.  

By the way, if you are not already doing this, be sure to exit the weatherservice after removing the panel applet.  Use the command: 
dcop KWeatherService WeatherService exit

Then make and make install the new version.  Then re-add the panel applet.

Any better luck with that version?

Thanks.
Comment 8 Unknown 2004-02-21 12:46:51 UTC
Ah! Thanks for helping me locate the failing module! sun.cpp has a small error in the way it converts UTC to Local time. Really, only two lines needed modification. UTC offset is in +/- hoursminutes which, in my locale is -500. This number has to be converted to a time friendly version. Dividing this by 100 yields hour.minutes (decimal format) and then this number can be manipulated. In both the computeRiseTime and computeSetTime functions, the line

QDateTime localDateTime = gmtDateTime.addSecs(localUTCOffset * 60);

has to be changed to ...localUTCOffset / 100 * 60);

Apparently, localUTCOffset is minutes, not seconds. -500/100 * 60 = 300 minutes = 5 hours. Prior computation had -500 * 60 = -30000 which explained the wacky sunrise and sunrise times I uploaded as snapshots.

I have uploaded a snapshot showing the correct results along with a patch.  Thanks for pointing me in the right direction. I will leave it to the maintainers to mark this bug as resolved.
Comment 9 Unknown 2004-02-21 12:49:29 UTC
Created attachment 4813 [details]
Patch file for sun.cpp

corrects localUTCOffset coversion to minutes
Comment 10 Unknown 2004-02-21 12:50:17 UTC
Created attachment 4814 [details]
Snapshot showing correct sunrise and sunset times per patch
Comment 11 Unknown 2004-02-21 12:58:32 UTC
I spoke too quickly, sunrise and sunset times are off by an hour or so each way

Actual sunrise time here is 6:45 AM, 
Actual sunset time here is 5:41 PM 

not 5:46 AM, and 6:35 PM as reported by the program. I think the function where lat and long are being computed need to be looked at??? At least we got the UTC stuff done. Is it possible that sunrise and sunset are reversed and the function computeRiseTime is really computeSetTime and vice versa?
Comment 12 Jonathan Hutchins 2004-02-21 15:57:23 UTC
I'm having a similar problem - sunset consistently reports 12:38 pm.  Sunrise, reported today at 6:00 am, looks reasonable but should be 7:03.  (Sunset should be 6:02 pm).

I also note the "Clear" icon, a blue lozenge, is rather ugly.
Comment 13 Unknown 2004-02-21 17:02:12 UTC
I'm stumped now. I can get the proper sunrise and sunset time to compute ON PROGRAM ENTRY. But as soon as report is selected, it borks and goes off by an additional 60 * localUTCOffset seconds. I think the error is in the module weatherservice.cpp where it calls the computeRiseTime and SetTime functions are called and possibly in sun.h where a reference to localUTCOffset is fixed in the functions.  I'll leave this to greater minds than mine to tackle. I'm out of ideas.

Initial program entry results. Note, correct local times.

kweatherservice: Wind Chill: 35.5328
kweatherservice: current, rise, set, offset: 10:21:47 06:41:17 17:38:03 -300
kweatherservice: Clouds: 7, Icon: cloudy3
kweatherservice: Sending update for KTTN

Subsequent reports or updates, show completely different, middle of the night times for sunrise.

kweatherservice: Pressure: A2956-A-2956
kweatherservice: Wind Chill: 35.5328
kweatherservice: current, rise, set, offset: 10:57:40 01:10:13 13:17:10 -300
kweatherservice: Clouds: 7, Icon: cloudy3
kweatherservice: Sending update for kttn
Comment 14 John Ratke 2004-02-21 19:50:40 UTC
The problem is with the station ID.   Notice that the first time you request update for "KTTN" and it is OK, but the next time you request update for "kttn", and it is wrong.  

So we probably just have to upper case that station at some point.  (Permanently)

I am leaving for a bit, but I can try to look at this and fix it when I get back in a few hours, if no one has tracked it down by then.

Comment 15 John Ratke 2004-02-21 23:51:03 UTC
OK, I committed some code to better handle unknown stations, and upper case station ids passed in to the DCOP funcitons.

Does that help?
Comment 16 Unknown 2004-02-22 00:11:45 UTC
No. First time through was sort of OK. There is a problem with the parsing for latitude  and longitude where the mid( parsing is starting one character too early. But the time is still wrong on subsequent reports. there is a continuing problem converting localUTCOffset:

Here is the error in the mid function in the latitudeToDouble function:
	/* Peter Hyman: extended mid parsing to position 4 */
	double mm = latitude.mid(3, 2).toDouble();
and the longitudeToDouble function	
	/* Peter Hyman: extended mid parsing to position 5 */
	double mm  = longitude.mid(5, 2).toDouble();

Here's the program output:
(note on the weather report screen, the location is no longer shown at all. and note how the location becomes lower case when the report is called. What a Pandora's box I opened)!

kweatherservice: Wind Chill: 37.7276
kweatherservice: station, current, lat, lon, rise, set, offset: KTTN 17:59:08 40-16-35N 074-48-59W 06:17:19 18:08:25 -300
kweatherservice: Clouds: 11, Icon: cloudy4
kweatherservice: Sending update for KTTN
kweather: refresh KTTN
kweatherservice: Searching for job...
kweather: Showing out the report
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-peter/ksycoca
kweatherservice: Get the current weather icon..
kweatherservice: Returning kttn
kweatherservice: station, lat, lon, rise time: kttn   00:49:16
kweatherservice: station, lat, lon, set time: kttn   13:38:07
Comment 17 Unknown 2004-02-22 13:49:25 UTC
John, good work! Only problem that remains is in the sunrise and sunset functions, you make a call to the macro civil_twilight which returns those times, not the actual sunrise sunset times. The correct marco to call would be sun_rise_set. I have made those changes.  In addition, I have created two new functions that WILL show the civil twilight times in the weather report. I am submitting a complete diff file for your review. I could not get the debug output to show the civil twilight data (I could not find out where to call it from).

In addition, I am also posting a screen shot.

Thanks for your excellent work in tracking down this problem, John! I will leave it to you to mark this bug as resolved.
Comment 18 Unknown 2004-02-22 13:51:38 UTC
Created attachment 4836 [details]
patch file for modules including Civil Twilight mods

Includes mods to reportview sun weatherservice cpp files and headers
Comment 19 Unknown 2004-02-22 13:54:46 UTC
Created attachment 4837 [details]
snapshot showing result of civil twilight mods
Comment 20 Unknown 2004-02-22 20:52:14 UTC
night icons still showing during day after update:

kweatherservice: Parse:  2004/02/22 18:53 KTTN 221853Z 29015KT 10SM CLR 07/M08 A3006 RMK AO2 SLP176 T00721078
kweatherservice: Processing data:  2004/02/22 18:53 KTTN 221853Z 29015KT 10SM CLR 07/M08 A3006 RMK AO2 SLP176 T00721078
kweatherservice: Processing Token: 2004/02/22
kweatherservice: Date: 2004/02/22-2004/02/22
kweatherservice: Processing Token: 18:53
kweatherservice: Time: 18:53-18:53
clip
kweatherservice: station, current, lat, lon, rise, set, offset: kttn 14:47:58 Unknown Station Unknown Station 01:10:06 13:17:02
-300
kweatherservice: Clouds: 0, Icon: sunny_night

Boy, this is a stubborn one.
Comment 21 Unknown 2004-02-26 20:17:19 UTC
kweatherservice: Get the current weather icon..
kweatherservice: Returning kttn
kweatherservice: station, lat, lon, rise time: KTTN 40-16-35N 074-48-59W 06:10:22
kweatherservice: station, lat, lon, set time: KTTN 40-16-35N 074-48-59W 18:13:58

Still picking up civil twilight times, not surise/sunset times.

Thursday 
        26 February 2004      Eastern Standard Time          

                         SUN
        Begin civil twilight       6:11 a.m.                 
        Sunrise                    6:38 a.m.                 
        Sun transit               12:12 p.m.                 
        Sunset                     5:47 p.m.                 
        End civil twilight         6:14 p.m.                 

Comment 22 David M. Carney 2004-02-26 22:50:18 UTC
I'm new to CVS. I'm having the same problems with the icons. I downloaded the "latest" kdetoys (with kweather) just now. There's no configure script. How do I compile it??

David
Comment 23 John Ratke 2004-02-27 03:27:39 UTC
David,

This guide might be helpful:
http://developer.kde.org/build/newbie_build_cvs.html

But I think you need to do "make -f Makefile.cvs" from the kdetoys directory level.  Then you should be able to run configure.

Comment 24 John Ratke 2004-02-29 18:15:27 UTC
-------- Original Message --------
Subject: 	kdetoys/kweather
Date: 	Sun, 29 Feb 2004 18:10:30 +0100 (CET)
From: 	John Ratke <jratke@comcast.net>
Reply-To: 	kde-cvs@kde.org
To: 	kde-cvs@kde.org



CVS commit by jratke: 


This patch adds support for calculation of both civil twilight and the exact
sun rise and set times.  It will display the civil twilight start and end
times in the weather report.  The isNight calculation is still based on
the civil twilight times.  

This is based on the idea and patch from Peter Hyman.

This patch also removes the unused member variables from the reportView class.


  M +8 -0      reportview.cpp   1.40
  M +0 -15     reportview.h   1.15
  M +53 -33    sun.cpp   1.10
  M +26 -8     sun.h   1.6
  M +8 -7      weatherlib.cpp   1.86
  M +38 -25    weatherservice.cpp   1.33
  M +16 -5     weatherservice.h   1.24





Comment 25 John Ratke 2004-03-06 19:58:21 UTC
*** Bug has been marked as fixed ***.
Comment 26 Berck E. Nash 2004-08-26 20:44:52 UTC
I filed Bug #87642, because these problems are still not resolved in KDE 3.3 as provided by debian-unstable.  It sure doesn't seem like a debian problem.

Lowercase ICAO provide nonsense for sunrise/sunset.  Uppercase ICAO identifiers cause KDE to report Sunrise/Sunset times as civil twighlight times.  The twighlight times are correct, but KDE insists that they are sunrise/sunset times.