[LON-CAPA-cvs] cvs: loncom /auth lonauth.pm /interface lonnavmaps.pm /localize lonlocal.pm

www lon-capa-cvs@mail.lon-capa.org
Thu, 10 Nov 2005 19:19:52 -0000


www		Thu Nov 10 14:19:52 2005 EDT

  Modified files:              
    /loncom/auth	lonauth.pm 
    /loncom/interface	lonnavmaps.pm 
    /loncom/localize	lonlocal.pm 
  Log:
  Display timezone for absolute dates and times.
  
  
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.70 loncom/auth/lonauth.pm:1.71
--- loncom/auth/lonauth.pm:1.70	Mon Oct 24 17:32:42 2005
+++ loncom/auth/lonauth.pm	Thu Nov 10 14:19:08 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.70 2005/10/24 21:32:42 albertel Exp $
+# $Id: lonauth.pm,v 1.71 2005/11/10 19:19:08 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -40,6 +40,7 @@
 use Apache::lonmenu();
 use Fcntl qw(:flock);
 use Apache::lonlocal;
+use POSIX qw(mktime);
 
 my %FORM;
 
@@ -152,6 +153,19 @@
            print $idf "browser.localpath=$FORM{'localpath'}\n";
            print $idf "browser.localres=$FORM{'localres'}\n";
         }
+        print $idf "server.domain=".$r->dir_config('lonDefDomain')."\n";
+        my $timezone='UTC';
+        my $timediff=POSIX::mktime(localtime())-POSIX::mktime(gmtime());
+        if ($timediff) {
+	    my $hours=int($timediff/3600);
+            my $minutes=abs(int(($timediff-$hours*3600)/60));
+            my $sign="+";
+            if ($timediff<0) {
+		$sign="-";
+	    }
+            $timezone.=$sign.abs($hours).':'.substr("0$minutes",-2);
+	}
+        print $idf "server.timezone=$timezone\n";
 	print $idf "request.course.fn=\n";
 	print $idf "request.course.uri=\n";
 	print $idf "request.course.sec=\n";
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.346 loncom/interface/lonnavmaps.pm:1.347
--- loncom/interface/lonnavmaps.pm:1.346	Tue Nov  8 07:01:42 2005
+++ loncom/interface/lonnavmaps.pm	Thu Nov 10 14:19:26 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.346 2005/11/08 12:01:42 foxr Exp $
+# $Id: lonnavmaps.pm,v 1.347 2005/11/10 19:19:26 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -602,6 +602,8 @@
 # print "Answer available $timestring"
 # Very, very, very, VERY English-only... goodness help a localizer on
 # this func...
+
+
 sub timeToHumanString {
     my ($time,$type,$format) = @_;
 
@@ -679,7 +681,7 @@
 
 	if($format ne '') {
 	    my $timeStr = strftime($format, localtime($time));
-	    return $timeStr;
+	    return $timeStr.&Apache::lonlocal::gettimezone();
 	}
 
         # Less then 5 days away, display day of the week and
@@ -690,7 +692,7 @@
             $timeStr =~ s/12:00 am/00:00/;
             $timeStr =~ s/12:00 pm/noon/;
             return ($inPast ? "last " : "this ") .
-                $timeStr;
+                $timeStr.&Apache::lonlocal::gettimezone();
         }
         
 	my $conjunction='on';
@@ -705,14 +707,14 @@
             my $timeStr = strftime("$conjunction %A, %b %e at %I:%M %P", localtime($time));
             $timeStr =~ s/12:00 am/00:00/;
             $timeStr =~ s/12:00 pm/noon/;
-            return $timeStr;
+            return $timeStr.&Apache::lonlocal::gettimezone();
         }
 
         # Not this year, so show the year
         my $timeStr = strftime("$conjunction %A, %b %e %Y at %I:%M %P", localtime($time));
         $timeStr =~ s/12:00 am/00:00/;
         $timeStr =~ s/12:00 pm/noon/;
-        return $timeStr;
+        return $timeStr.&Apache::lonlocal::gettimezone();
     }
 }
 
Index: loncom/localize/lonlocal.pm
diff -u loncom/localize/lonlocal.pm:1.34 loncom/localize/lonlocal.pm:1.35
--- loncom/localize/lonlocal.pm:1.34	Wed Jun 22 01:04:51 2005
+++ loncom/localize/lonlocal.pm	Thu Nov 10 14:19:51 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Localization routines
 #
-# $Id: lonlocal.pm,v 1.34 2005/06/22 05:04:51 albertel Exp $
+# $Id: lonlocal.pm,v 1.35 2005/11/10 19:19:51 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -259,11 +259,14 @@
 }
 
 # ========================================================== Localize localtime
+sub gettimezone {
+    return ' ('.$Apache::lonnet::env{'server.timezone'}.')';
+}
 
 sub locallocaltime {
     my $thistime=shift;
     if ((&current_language=~/^en/) || (!$lh)) {
-	return ''.localtime($thistime);
+	return ''.localtime($thistime).&gettimezone();
     } else {
 	my $format=$lh->maketext('date_locale');
 	if ($format eq 'date_locale') {
@@ -293,7 +296,7 @@
 	 'month','weekday','ampm') {
 	    $format=~s/\$$_/eval('$'.$_)/gse;
 	}
-	return $format;
+	return $format.&gettimezone();
     }
 }