Display full hwclock error message
authorJamie Cameron <jcameron@webmin.com>
Tue, 27 Nov 2007 05:22:00 +0000 (05:22 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 27 Nov 2007 05:22:00 +0000 (05:22 +0000)
time/CHANGELOG
time/index.cgi
time/lang/en
time/time-lib.pl

index 251097f..dd96f37 100644 (file)
@@ -11,3 +11,5 @@ Added an API for getting and setting the system and hardware times, for calling
 When the hardware or system time is not editable due to module access control restrictions, the times are now displayed (but cannot be changed).
 ---- Changes since 1.340 ----
 Added check for empty timeservers field.
+---- Changes since 1.380 ----
+Display a more complete message if unable to get the hardware time from hwclock.
index 665649f..6f3e452 100755 (executable)
@@ -58,7 +58,7 @@ else
 # Get the hardware time
 if ($config{'hwtime'}) {
        local @tm = &get_hardware_time();
-       @tm || &error($text{'index_eformat'});
+       @tm || &error($get_hardware_time_error || $text{'index_eformat'});
        $hw_date{ 'second' } = $tm[0];
        $hw_date{ 'minute' } = $tm[1];
        $hw_date{ 'hour' } = $tm[2];
index b4bf3c4..ea0c919 100644 (file)
@@ -9,6 +9,7 @@ index_sync=Sync and Apply
 index_hardware2=Set hardware time too
 index_tzheader=Time Zone
 index_tz=Change timezone to
+index_ehwclock=$1 failed : $2
 
 action_save=Save
 action_apply=Apply
index 8d95205..1f35d43 100755 (executable)
@@ -172,10 +172,12 @@ else {
 }
 
 # get_hardware_time()
-# Returns the current hardware time, in localtime format
+# Returns the current hardware time, in localtime format. On failure returns
+# an empty array, and sets the global $get_hardware_time_error
 sub get_hardware_time
 {
 local $flags = &get_hwclock_flags();
+$get_hardware_time_error = undef;
 local $out = `hwclock $flags`;
 if ($out =~ /^(\S+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)\s+/) {
        return ($6, $5, $4, $3, &month_to_number($2), $7-1900, &weekday_to_number($1));
@@ -184,6 +186,9 @@ elsif ($out =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(am|pm)\s+/
        return ($7, $6, $5+($8 eq 'pm' ? 12 : 0), $2, &month_to_number($3), $4-1900, &weekday_to_number($1));
        }
 else {
+       $get_hardware_time_error = &text('index_ehwclock',
+                       "<tt>".&html_escape("hwclock $flags")."</tt>",
+                       "<pre>".&html_escape($out)."</pre>");
        return ( );
        }
 }