aboutsummaryrefslogtreecommitdiff
path: root/libmap/test-timezone.c
diff options
context:
space:
mode:
authorkarl-qdh <karl@qdh.org.uk>2011-02-25 17:22:33 +0000
committerkarl-qdh <karl@qdh.org.uk>2011-02-25 17:22:33 +0000
commit0188356e069018c07849f8c2c09c9741bbf70ff5 (patch)
treea0ba2047125ba0ada887f2722ea0c11a52fd9792 /libmap/test-timezone.c
parentd0e5a69a026bc879759cde57f8ba324c67b6b37a (diff)
parent6f103ce25995b5a40967b0ba683b7f7330aadd8a (diff)
downloadayatana-indicator-datetime-0188356e069018c07849f8c2c09c9741bbf70ff5.tar.gz
ayatana-indicator-datetime-0188356e069018c07849f8c2c09c9741bbf70ff5.tar.bz2
ayatana-indicator-datetime-0188356e069018c07849f8c2c09c9741bbf70ff5.zip
Updated to newest trunk needs more merging
Diffstat (limited to 'libmap/test-timezone.c')
-rw-r--r--libmap/test-timezone.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/libmap/test-timezone.c b/libmap/test-timezone.c
new file mode 100644
index 0000000..c1935fd
--- /dev/null
+++ b/libmap/test-timezone.c
@@ -0,0 +1,56 @@
+#include <config.h>
+#include <locale.h>
+
+#include "tz.h"
+
+int main (int argc, char **argv)
+{
+ TzDB *db;
+ GPtrArray *locs;
+ guint i;
+ char *pixmap_dir;
+ int retval = 0;
+
+ setlocale (LC_ALL, "");
+
+ if (argc == 2) {
+ pixmap_dir = g_strdup (argv[1]);
+ } else if (argc == 1) {
+ pixmap_dir = g_strdup ("data/");
+ } else {
+ g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]);
+ return 1;
+ }
+
+ db = tz_load_db ();
+ locs = tz_get_locations (db);
+ for (i = 0; i < locs->len ; i++) {
+ TzLocation *loc = locs->pdata[i];
+ TzInfo *info;
+ char *filename, *path;
+ gdouble selected_offset;
+ char buf[16];
+
+ info = tz_info_from_location (loc);
+ selected_offset = tz_location_get_utc_offset (loc)
+ / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0);
+
+ filename = g_strdup_printf ("timezone_%s.png",
+ g_ascii_formatd (buf, sizeof (buf),
+ "%g", selected_offset));
+ path = g_build_filename (pixmap_dir, filename, NULL);
+
+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {
+ g_message ("File '%s' missing for zone '%s'", filename, loc->zone);
+ retval = 1;
+ }
+
+ g_free (filename);
+ g_free (path);
+ tz_info_free (info);
+ }
+ tz_db_free (db);
+ g_free (pixmap_dir);
+
+ return retval;
+}