diff options
author | Callum McKenzie <callum@src.gnome.org> | 2007-07-12 08:52:56 +0000 |
---|---|---|
committer | Callum McKenzie <callum@src.gnome.org> | 2007-07-12 08:52:56 +0000 |
commit | 2a5e847ee965a79e3c26c976d53e0566496faa7d (patch) | |
tree | 93cb924c7c63e425fff61aa804e3d8b565fd3a61 | |
parent | e5b70405ea8ac0f566f1e25ae3797f137a244df6 (diff) |
Fixes to sunrise, sunset and update time calculations. See bug 455012.
svn path=/trunk/; revision=10286
-rw-r--r-- | libgweather/ChangeLog | 13 | ||||
-rw-r--r-- | libgweather/weather-metar.c | 11 | ||||
-rw-r--r-- | libgweather/weather-sun.c | 5 |
3 files changed, 23 insertions, 6 deletions
diff --git a/libgweather/ChangeLog b/libgweather/ChangeLog index 3dc80ecb8..cd8215331 100644 --- a/libgweather/ChangeLog +++ b/libgweather/ChangeLog @@ -1,3 +1,16 @@ +2007-07-12 Callum McKenzie <callum@spooky-possum.org> + + * weather-metar.c (make_time): Fix the logic to only fiddle the + day number on the 1st. Based on Elliott Hughes patch from bug + #455012. Improved comments. + +2007-07-11 Callum McKenzie <callum@spooky-possum.org> + + * weather-sun.c (calc_sun): Use the current time rather than the + observation time to calculate the sunrise and sunset times. Fixes + the case where the observation gets horribly out of date. See bug + #455012. + 2007-05-13 Kjartan Maraas <kmaraas@gnome.org> * Makefile.am: Add GNOME_APPLETS_CFLAGS to get diff --git a/libgweather/weather-metar.c b/libgweather/weather-metar.c index ffde2bd12..f3620f3b7 100644 --- a/libgweather/weather-metar.c +++ b/libgweather/weather-metar.c @@ -49,10 +49,13 @@ static time_t make_time (gint utcDate, gint utcHour, gint utcMin) localtime_r (&now, &tm); - /* If last reading took place just before midnight UTC on the first, adjust the - * date downward. This ASSUMES that the reading won't be more than 24 hrs old! */ - if (utcDate > tm.tm_mday) { - tm.tm_mday--; + /* If last reading took place just before midnight UTC on the + * first, adjust the date downward to allow for the month + * change-over. This ASSUMES that the reading won't be more than + * 24 hrs old! */ + if ((utcDate > tm.tm_mday) && (tm.tm_mday == 1)) { + tm.tm_mday = 0; /* mktime knows this is the last day of the previous + * month. */ } else { tm.tm_mday = utcDate; } diff --git a/libgweather/weather-sun.c b/libgweather/weather-sun.c index f4a876365..da730fee2 100644 --- a/libgweather/weather-sun.c +++ b/libgweather/weather-sun.c @@ -208,9 +208,10 @@ static gboolean calc_sun2 (time_t t, gdouble obsLat, gdouble obsLon, gboolean calc_sun (WeatherInfo *info) { + time_t now = time (NULL); + return info->location->latlon_valid - && calc_sun2(info->update, - info->location->latitude, info->location->longitude, + && calc_sun2(now, info->location->latitude, info->location->longitude, &info->sunrise, &info->sunset); } |