Hi Marek, On Tue, May 11, 2010 at 12:03:53PM +0200, Marek Otahal wrote: > I'd like to send a patch that adds support for pretty printing of current > RTC's alarms. > > The thing it actually does is convert RTC time to local time. > To do this (pseudocode): > rtc=get rtc alarm's time from rtc dev; > time_diff= (-timezone+daylight*3600); -where timezone and daylight are extern > constants from time.h; > now just add the time_diff to time_t representation of rtc, ^^^^^^^^ I think this is not correct. The RTC time could be in local time. This is reason why rtcwake reads /etc/adjtime, see the read_clock_mode() function. (Please, see in the main() how rtcwake modifies 'alarm' (-t option) variable to convert from local to rtc time.) > int main(int argc, char **argv) > { > char *devname = DEFAULT_DEVICE; > @@ -345,6 +411,7 @@ > || strcmp(optarg, "no") == 0 > || strcmp(optarg, "off") == 0 > || strcmp(optarg, "disable") == 0 > + || strcmp(optarg, "show") == 0 > ) { > suspend = strdup(optarg); > break; > @@ -404,6 +471,9 @@ > } > } > > + if (strcmp(suspend, "show") == 0) { > + clock_mode = CM_LOCAL; > + } It would be better to not modify clock_mode and call read_clock_mode() and get_basetimes() to get sys_time and rtc_time... > if (clock_mode == CM_AUTO) { > if (read_clock_mode() < 0) { > printf(_("%s: assuming RTC uses UTC ...\n"), > progname); > @@ -414,7 +484,7 @@ > printf(clock_mode == CM_UTC ? _("Using UTC time.\n") : > _("Using local time.\n")); [...] > + > + } else if(strcmp(suspend,"show") == 0) { > + if (verbose) > + printf(_("suspend mode: show; printing alarm > info\n")); > + if(print_alarm_info(fd) != 0) ... and read alarm time (by RTC_WKALM_RD / RTC_ALM_READ) to 'alarm' variable and then make the correction (according to diff between sys_time and rtc_time) and print the final time (by ctime() or so..). Karel -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html