summaryrefslogtreecommitdiff
path: root/src/test/timezones.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/timezones.c')
-rw-r--r--src/test/timezones.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/test/timezones.c b/src/test/timezones.c
index ac8598f..f55b33c 100644
--- a/src/test/timezones.c
+++ b/src/test/timezones.c
@@ -29,6 +29,7 @@ int main(int argc, char **argv)
int ret = 0;
unsigned int total_failed = 0;
unsigned int total_okay = 0;
+ unsigned int percent_failed = 0;
int verbose = 0;
icaltimezone *utc_zone = icaltimezone_get_utc_timezone();
@@ -44,23 +45,34 @@ int main(int argc, char **argv)
struct icaltimetype curr_tt;
int failed = 0;
int curr_failed;
+ int zonedef_printed = 0;
/*
* select this location for glibc: needs support for TZ=<location>
* which is not POSIX
*/
+#if defined(HAVE_SETENV)
setenv("TZ", zone_location, 1);
+#else
+ static new_tz[256];
+ new_tz[0] = '\0';
+ strncat(new_tz, "TZ=", 255);
+ strncat(new_tz, zone_location, 255);
+ putenv(new_tz);
+#endif
tzset();
/*
* determine current local time and date: always use midday in
- * the current zone
+ * the current zone and first day of first month in the year
*/
start_time = time(NULL);
localtime_r(&start_time, &start_tm);
start_tm.tm_hour = 12;
start_tm.tm_min = 0;
start_tm.tm_sec = 0;
+ start_tm.tm_mday = 1;
+ start_tm.tm_mon = 0;
start_time = mktime(&start_tm);
/* check time conversion for the next 365 days */
@@ -85,13 +97,23 @@ int main(int argc, char **argv)
/* only print first failed day and first day which is okay again */
if (verbose || curr_failed != failed) {
- printf("%s: day %03d: %s: libc %04d-%02d-%02d %02d:%02d:%02d dst %d",
+ struct tm utc_tm;
+ gmtime_r(&curr_time, &utc_tm);
+ printf("%s: day %03d: %s: %04d-%02d-%02d %02d:%02d:%02d UTC = libc %04d-%02d-%02d %02d:%02d:%02d dst %d",
zone_location,
day,
+
verbose ?
(curr_failed ? "failed" : "okay") :
(curr_failed ? "first failed" : "okay again"),
+ utc_tm.tm_year + 1900,
+ utc_tm.tm_mon + 1,
+ utc_tm.tm_mday,
+ utc_tm.tm_hour,
+ utc_tm.tm_min,
+ utc_tm.tm_sec,
+
curr_tm.tm_year + 1900,
curr_tm.tm_mon + 1,
curr_tm.tm_mday,
@@ -112,6 +134,14 @@ int main(int argc, char **argv)
}
printf("\n");
failed = curr_failed;
+
+ if (!zonedef_printed) {
+ icalcomponent *comp = icaltimezone_get_component(zone);
+ if (comp) {
+ printf("%s\n", icalcomponent_as_ical_string(comp));
+ }
+ zonedef_printed = 1;
+ }
}
if (curr_failed) {
@@ -123,11 +153,12 @@ int main(int argc, char **argv)
}
if (total_failed || total_okay) {
+ percent_failed = total_failed * 100 / (total_failed + total_okay);
printf(" *** Summary: %d zones tested, %u days failed, %u okay => %u%% failed ***\n",
timezones->num_elements,
total_failed,
total_okay,
- total_failed * 100 / (total_failed + total_okay));
+ percent_failed);
}
return ret;