[LON-CAPA-cvs] cvs: loncom /debugging_tools dump_db.pl

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 04 Sep 2003 14:32:46 -0000


matthew		Thu Sep  4 10:32:46 2003 EDT

  Modified files:              
    /loncom/debugging_tools	dump_db.pl 
  Log:
  Added automagic time localization command line option '-t'.
  
  
Index: loncom/debugging_tools/dump_db.pl
diff -u loncom/debugging_tools/dump_db.pl:1.2 loncom/debugging_tools/dump_db.pl:1.3
--- loncom/debugging_tools/dump_db.pl:1.2	Wed Sep  4 16:49:16 2002
+++ loncom/debugging_tools/dump_db.pl	Thu Sep  4 10:32:46 2003
@@ -4,7 +4,7 @@
 #
 # dump_db.pl - dump a GDBM database to standard output, unescaping if asked to.
 #
-# $Id: dump_db.pl,v 1.2 2002/09/04 20:49:16 matthew Exp $
+# $Id: dump_db.pl,v 1.3 2003/09/04 14:32:46 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,10 +35,10 @@
 
 #
 # Options
-my $unesc = 0;
-my $help = 0;
+my ($unesc,$help,$localize_times) = (0,0,0);
 GetOptions("unescape" => \$unesc,
            "u"        => \$unesc,
+           "t"        => \$localize_times,
            "help"     => \$help);
 
 #
@@ -52,7 +52,8 @@
 Options:
    --help     Display this help.
    --unescape Unescape the keys and values before printing them out.
-   --u        Same as --unescape
+   -u        Same as --unescape
+   -t        Localize times when possible (human readable times)
 Examples: 
     dump_db.pl mydata.db
     dump_db.pl mydata.db yourdata.db ourdata.db theirdata.db
@@ -73,6 +74,11 @@
         if ($unesc) {
             $key = &unescape($key);
             $value = &unescape($value);
+        }
+        if ($localize_times) {
+            if ($value =~ /^\s*([0-9]{10,10})\s*$/) {
+                $value = $value.' [ '.localtime($1).' ]';
+            }
         }
         print "$key = $value\n";
     }