summaryrefslogtreecommitdiff
path: root/libgweather/test_sun_moon.c
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2012-12-02 19:43:07 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2012-12-02 20:07:43 +0100
commitfdd771f355d2b9649d5835d4ddcf549c274ef353 (patch)
tree94c4482b673efd400fbf55e8dbea03739cd0588c /libgweather/test_sun_moon.c
parent3cb64a2e1285734214fea76cb999d11ffee4c49e (diff)
downloadlibgweather-fdd771f355d2b9649d5835d4ddcf549c274ef353.tar.gz
Remove WeatherLocation as a pointer type
WeatherLocation is now embedded inside GWeatherInfo, which was it's only user. It exists as a structure to avoid passing GWeatherInfo around, and to avoid changing the existing code too much, but it is no longer separately allocated.
Diffstat (limited to 'libgweather/test_sun_moon.c')
-rw-r--r--libgweather/test_sun_moon.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/libgweather/test_sun_moon.c b/libgweather/test_sun_moon.c
index de6a7b9..f384298 100644
--- a/libgweather/test_sun_moon.c
+++ b/libgweather/test_sun_moon.c
@@ -11,14 +11,13 @@ int
main (int argc, char **argv)
{
GWeatherInfo *info;
+ GWeatherInfoPrivate *priv;
GOptionContext* context;
GError* error = NULL;
gdouble latitude, longitude;
- WeatherLocation location;
gchar* gtime = NULL;
GDate gdate;
struct tm tm;
- gboolean bmoon;
time_t phases[4];
const GOptionEntry entries[] = {
{ "latitude", 0, 0, G_OPTION_ARG_DOUBLE, &latitude,
@@ -30,8 +29,6 @@ main (int argc, char **argv)
{ NULL }
};
- memset(&location, 0, sizeof(WeatherLocation));
-
context = g_option_context_new ("- test libgweather sun/moon calculations");
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_parse (context, &argc, &argv, &error);
@@ -48,12 +45,12 @@ main (int argc, char **argv)
return -1;
}
- location.latitude = DEGREES_TO_RADIANS(latitude);
- location.longitude = DEGREES_TO_RADIANS(longitude);
- location.latlon_valid = TRUE;
info = g_object_new (GWEATHER_TYPE_INFO, NULL);
- info->priv->location = _weather_location_clone(&location);
- info->priv->valid = TRUE;
+ priv = info->priv;
+ priv->location.latitude = DEGREES_TO_RADIANS(latitude);
+ priv->location.longitude = DEGREES_TO_RADIANS(longitude);
+ priv->location.latlon_valid = TRUE;
+ priv->valid = TRUE;
if (gtime != NULL) {
// printf(" gtime=%s\n", gtime);
@@ -72,14 +69,14 @@ main (int argc, char **argv)
fabs(longitude), (longitude >= 0. ? 'E' : 'W'),
asctime(gmtime(&priv->current_time)));
printf("sunrise: %s",
- (info->priv->sunriseValid ? ctime(&info->priv->sunrise) : "(invalid)\n"));
+ (priv->sunriseValid ? ctime(&priv->sunrise) : "(invalid)\n"));
printf("sunset: %s",
- (info->priv->sunsetValid ? ctime(&info->priv->sunset) : "(invalid)\n"));
- if (bmoon) {
- printf("moonphase: %g\n", info->priv->moonphase);
- printf("moonlat: %g\n", info->priv->moonlatitude);
+ (priv->sunsetValid ? ctime(&priv->sunset) : "(invalid)\n"));
+ if (priv->moonValid) {
+ printf("moonphase: %g\n", priv->moonphase);
+ printf("moonlat: %g\n", priv->moonlatitude);
- if (calc_moon_phases(info, phases)) {
+ if (gweather_info_get_upcoming_moonphases(info, phases)) {
printf(" New: %s", asctime(gmtime(&phases[0])));
printf(" 1stQ: %s", asctime(gmtime(&phases[1])));
printf(" Full: %s", asctime(gmtime(&phases[2])));