Allow editing of date format
authorJamie Cameron <jcameron@webmin.com>
Tue, 30 Oct 2007 17:39:40 +0000 (17:39 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 30 Oct 2007 17:39:40 +0000 (17:39 +0000)
usermin/CHANGELOG
usermin/change_ui.cgi
usermin/edit_ui.cgi
web-lib-funcs.pl
webmin/CHANGELOG
webmin/change_ui.cgi
webmin/edit_ui.cgi
webmin/lang/en
webmin/webmin-lib.pl

index 95722c2..c2b7c12 100644 (file)
@@ -34,3 +34,5 @@ Added an option to the Authentication page to block users with too many failed l
 Created the new Blocked Hosts and Users page to show blocks currently in force, and allow them to be cleared.
 ---- Changes since 1.360 ----
 Separated the Configure Module page into tabs, to make it clearer which options are global and which are default user preferences.
+---- Changes since 1.370 ----
+The format for dates displayed by Webmin can be changed by a new option on the User Interface page.
index 0bbb55d..10a02a9 100755 (executable)
@@ -34,6 +34,7 @@ $uconfig{'showlogin'} = $in{'showlogin'};
 $uconfig{'hostnamemode'} = $in{'hostnamemode'};
 $uconfig{'hostnamedisplay'} = $in{'hostnamedisplay'};
 $uconfig{'notabs'} = $in{'notabs'};
+$uconfig{'dateformat'} = $in{'dateformat'};
 &write_file($usermin_config, \%uconfig);
 &unlock_file($usermin_config);
 &webmin_log('ui', undef, undef, \%in);
index 7c344f5..c429398 100755 (executable)
@@ -116,6 +116,12 @@ printf "<input name=notabs type=radio value=0 %s> %s\n",
 printf "<input name=notabs type=radio value=1 %s> %s</td> </tr>\n",
        $uconfig{'notabs'} ? 'checked' : '', $text{'no'};
 
+print "<tr> <td><b>$webmin::text{'ui_dateformat'}</b></td> <td>\n";
+print &ui_select("dateformat", $uconfig{'dateformat'} || "dd/mon/yyyy",
+                  [ map { [ $_, $webmin::text{'ui_dateformat_'.$_} ] }
+                        @webmin_date_formats ]));
+print "</td> </tr>\n";
+
 print "</table></td></tr></table>\n";
 print "<input type=submit value=\"$text{'save'}\"></form>\n";
 
index 138cf30..78f8878 100755 (executable)
@@ -1160,16 +1160,27 @@ return $rv;
 # Converts a Unix date/time in seconds to a human-readable form
 sub make_date
 {
-local @tm = localtime($_[0]);
-if ($_[1]) {
-       return sprintf "%d/%s/%d",
+local ($secs, $only) = @_;
+local @tm = localtime($secs);
+local $date;
+local $fmt = $gconfig{'dateformat'} || 'dd/mon/yyyy';
+if ($fmt eq 'dd/mon/yyyy') {
+       $date = sprintf "%2.2d/%s/%4.4d",
                        $tm[3], $text{"smonth_".($tm[4]+1)}, $tm[5]+1900;
        }
-else {
-       return sprintf "%d/%s/%d %2.2d:%2.2d",
-                       $tm[3], $text{"smonth_".($tm[4]+1)},
-                       $tm[5]+1900, $tm[2], $tm[1];
+elsif ($fmt eq 'dd/mm/yyyy') {
+       $date = sprintf "%2.2d/%2.2d/%4.4d", $tm[3], $tm[4]+1, $tm[5]+1900;
+       }
+elsif ($fmt eq 'mm/dd/yyyy') {
+       $date = sprintf "%2.2d/%2.2d/%4.4d", $tm[4]+1, $tm[3], $tm[5]+1900;
+       }
+elsif ($fmt eq 'yyyy/mm/dd') {
+       $date = sprintf "%4.4d/%2.2d/%2.2d", $tm[5]+1900, $tm[4]+1, $tm[3];
+       }
+if (!$only) {
+       $date .= sprintf " %2.2d:%2.2d", $tm[2], $tm[1];
        }
+return $date;
 }
 
 # file_chooser_button(input, type, [form], [chroot], [addmode])
index 8d787bd..780fae3 100644 (file)
@@ -66,3 +66,5 @@ Created the new Blocked Hosts and Users page to show blocks currently in force,
 Added an option to the Ports and Addresses page to control if Webmin attempts to to reverse-resolve the connected-to IP address when issuing redirects, such as from non-SSL to SSL mode.
 ---- Changes since 1.360 ----
 Added a field to the Advanced Options page to control the number of days that files in /tmp/.webmin are kept before automatic deletion.
+---- Changes since 1.370 ----
+The format for dates displayed by Webmin can be changed by a new option on the User Interface page.
index c19c198..e6ed8db 100755 (executable)
@@ -23,6 +23,7 @@ $gconfig{'hostnamemode'} = $in{'hostnamemode'};
 $gconfig{'hostnamedisplay'} = $in{'hostnamedisplay'};
 $gconfig{'feedback_to'} = $in{'feedback_def'} ? undef : $in{'feedback'};
 $gconfig{'nofeedbackcc'} = $in{'nofeedbackcc'};
+$gconfig{'dateformat'} = $in{'dateformat'};
 
 $in{'width_def'} || $in{'width'} =~ /^\d+$/ || &error($text{'ui_ewidth'});
 $gconfig{'help_width'} = $in{'width'};
index 464443d..bfddc18 100755 (executable)
@@ -41,7 +41,10 @@ print &ui_table_row($text{'ui_feedbackmode'},
                  [ [ 0, $text{'yes'} ], [ 1, $text{'ui_feednocc'} ],
                    [ 2, $text{'no'} ] ]));
 
-# XXX date display format
+print &ui_table_row($text{'ui_dateformat'},
+       &ui_select("dateformat", $gconfig{'dateformat'} || "dd/mon/yyyy",
+                  [ map { [ $_, $text{'ui_dateformat_'.$_} ] }
+                        @webmin_date_formats ]));
 
 print &ui_table_row($text{'ui_width'},
        &ui_opt_textbox("width", $gconfig{'help_width'}, 5,
index 7cf639c..1f7b131 100644 (file)
@@ -161,6 +161,11 @@ ui_sizemodules=Multiple modules chooser size
 ui_edbwidth=Missing or invalid chooser window width
 ui_edbheight=Missing or invalid chooser window height
 ui_showlogin=Prepend username to page titles?
+ui_dateformat=Format for displayed dates
+ui_dateformat_dd/mon/yyyy=dd/mon/yyyy (ie. 16/Sep/2001)
+ui_dateformat_dd/mm/yyyy=dd/mm/yyyy (ie. 16/09/2001)
+ui_dateformat_mm/dd/yyyy=mm/dd/yyyy (ie. 09/16/2001)
+ui_dateformat_yyyy/mm/dd=yyyy/mm/dd (ie. 2001/09/16)
 
 mods_title=Webmin Modules
 mods_desc1=Webmin modules can be added after installation by using the form to the right. Modules are typically distributed in <tt>.wbm</tt> files, each of which can contain one or more modules. Modules can also be installed from RPM files if supported by your operating system.
index 0c1ad36..95128ab 100644 (file)
@@ -38,6 +38,9 @@ $os_info_address = "os\@webmin.com";
 
 $detect_operating_system_cache = "$module_config_directory/oscache";
 
+@webmin_date_formats = ( "dd/mon/yyyy", "dd/mm/yyyy",
+                        "mm/dd/yyyy", "yyyy/mm/dd" );
+
 sub setup_ca
 {
 local $adir = &module_root_directory("acl");