- r = time_get_dst(sec, "/etc/localtime",
- &tc, &zc, &is_dstc,
- &tn, &dn, &zn, &is_dstn);
- if (r < 0)
- printf(" DST active: n/a\n");
- else {
+ if (have_time) {
+ r = time_get_dst(sec, "/etc/localtime",
+ &tc, &zc, &is_dstc,
+ &tn, &dn, &zn, &is_dstn);
+ if (r < 0)
+ printf(" DST active: %s\n", "n/a");
+ else {
+ printf(" DST active: %s\n", yes_no(is_dstc));
+
+ t = tc - 1;
+ xstrftime(a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&t, &tm));
+
+ xstrftime(b, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&tc, &tm));
+ printf(" Last DST change: DST %s at\n"
+ " %.*s\n"
+ " %.*s\n",
+ is_dstc ? "began" : "ended",
+ (int) sizeof(a), a,
+ (int) sizeof(b), b);
+
+ t = tn - 1;
+ xstrftime(a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&t, &tm));
+ xstrftime(b, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&tn, &tm));
+ printf(" Next DST change: DST %s (the clock jumps %s) at\n"
+ " %.*s\n"
+ " %.*s\n",
+ is_dstn ? "begins" : "ends",
+ jump_str(dn, s, sizeof(s)),
+ (int) sizeof(a), a,
+ (int) sizeof(b), b);
+ }
+ } else