[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonmeta.pm /publisher lonpublisher.pm

www lon-capa-cvs@mail.lon-capa.org
Fri, 18 Oct 2002 13:49:50 -0000


www		Fri Oct 18 09:49:50 2002 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonmeta.pm 
    /loncom/publisher	lonpublisher.pm 
  Log:
  Toward bug 839
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.69 loncom/interface/loncommon.pm:1.70
--- loncom/interface/loncommon.pm:1.69	Tue Sep 17 11:21:51 2002
+++ loncom/interface/loncommon.pm	Fri Oct 18 09:49:49 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.69 2002/09/17 15:21:51 matthew Exp $
+# $Id: loncommon.pm,v 1.70 2002/10/18 13:49:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1221,6 +1221,22 @@
          $th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,$th{'dlsav'}));
 }
 
+
+#########################################
+#
+# Retro-fixing of un-backward-compatible time format
+
+sub unsqltime {
+    my $timestamp=shift;
+    if ($timestamp=~/^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/) {
+       $timestamp=&maketime(
+	   'year'=>$1,'month'=>$2,'day'=>$3,
+           'hours'=>$4,'minutes'=>$5,'seconds'=>$6);
+    }
+    return $timestamp;
+}
+
+#########################################
 
 sub findallcourses {
     my %courses=();
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.21 loncom/interface/lonmeta.pm:1.22
--- loncom/interface/lonmeta.pm:1.21	Mon Oct  7 09:50:36 2002
+++ loncom/interface/lonmeta.pm	Fri Oct 18 09:49:49 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.21 2002/10/07 13:50:36 www Exp $
+# $Id: lonmeta.pm,v 1.22 2002/10/18 13:49:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -180,8 +180,10 @@
 
 # --------------------------------------------------------------- Render Output
   my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta/);
-my $creationdate=localtime($content{'creationdate'});
-my $lastrevisiondate=localtime($content{'lastrevisiondate'});
+my $creationdate=localtime(
+ &Apache::loncommon::unsqltime($content{'creationdate'}));
+my $lastrevisiondate=localtime(
+ &Apache::loncommon::unsqltime($content{'lastrevisiondate'}));
 my $language=&Apache::loncommon::languagedescription($content{'language'});
 my $mime=&Apache::loncommon::filedescription($content{'mime'}); 
 my $disuri=&Apache::lonnet::declutter($uri);
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.102 loncom/publisher/lonpublisher.pm:1.103
--- loncom/publisher/lonpublisher.pm:1.102	Thu Oct 10 11:05:36 2002
+++ loncom/publisher/lonpublisher.pm	Fri Oct 18 09:49:49 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.102 2002/10/10 15:05:36 www Exp $
+# $Id: lonpublisher.pm,v 1.103 2002/10/18 13:49:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -139,9 +139,6 @@
 my $cuname;
 my $cudom;
 
-#########################################
-#########################################
-
 =pod
 
 =item B<metaeval>
@@ -265,46 +262,6 @@
 }
 
 #########################################
-#########################################
-
-=pod
-
-=item B<sqltime>
-
-Convert 'time' format into a datetime sql format
-
-Parameters:
-
-=over 4
-
-=item I<$timef>
-
-Seconds since 00:00:00 UTC, January 1, 1970.
-
-=back
-
-Returns:
-
-=over 4
-
-=item Scalar string
-
-MySQL-compatible datetime string.
-
-=back
-
-=cut
-
-#########################################
-#########################################
-sub sqltime {
-    my $timef=shift @_;
-    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
-	localtime($timef);
-    $mon++; $year+=1900;
-    return "$year-$mon-$mday $hour:$min:$sec";
-}
-
 
 #########################################
 #########################################
@@ -1124,7 +1081,8 @@
         unless ($metadatafields{'creationdate'}) {
 	    $metadatafields{'creationdate'}=time;
         }
-        $scrout.=&hiddenfield('creationdate',$metadatafields{'creationdate'});
+        $scrout.=&hiddenfield('creationdate',
+              &Apache::loncommon::unsqltime($metadatafields{'creationdate'}));
 
         $scrout.=&hiddenfield('lastrevisiondate',time);
 
@@ -1249,10 +1207,8 @@
     $metadatafields{'abstract'}=$ENV{'form.abstract'};
     $metadatafields{'mime'}=$ENV{'form.mime'};
     $metadatafields{'language'}=$ENV{'form.language'};
-    $metadatafields{'creationdate'}=
-        &sqltime($ENV{'form.creationdate'});
-    $metadatafields{'lastrevisiondate'}=
-        &sqltime($ENV{'form.lastrevisiondate'});
+    $metadatafields{'creationdate'}=$ENV{'form.creationdate'};
+    $metadatafields{'lastrevisiondate'}=$ENV{'form.lastrevisiondate'};
     $metadatafields{'owner'}=$ENV{'form.owner'};
     $metadatafields{'copyright'}=$ENV{'form.copyright'};
     $metadatafields{'dependencies'}=$ENV{'form.dependencies'};