Diff for /loncom/interface/lonnavmaps.pm between versions 1.402 and 1.403

version 1.402, 2007/10/05 18:48:20 version 1.403, 2007/10/18 21:08:08
Line 36  use Apache::lonenc(); Line 36  use Apache::lonenc();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonnet;  use Apache::lonnet;
 use POSIX qw (floor strftime);  use POSIX qw (floor strftime);
 use Data::Dumper; # for debugging, not always   
 use Time::HiRes qw( gettimeofday tv_interval );  use Time::HiRes qw( gettimeofday tv_interval );
 use LONCAPA;  use LONCAPA;
   use DateTime();
   
 # symbolic constants  # symbolic constants
 sub SYMB { return 1; }  sub SYMB { return 1; }
Line 305  sub timeToHumanString { Line 305  sub timeToHumanString {
     }       } 
     my $now = time();      my $now = time();
   
     my @time = localtime($time);  
     my @now = localtime($now);  
   
     # Positive = future      # Positive = future
     my $delta = $time - $now;      my $delta = $time - $now;
   
Line 366  sub timeToHumanString { Line 363  sub timeToHumanString {
             return "$prefix$hourString$minuteString$tense";              return "$prefix$hourString$minuteString$tense";
         }          }
   
    my $dt = DateTime->from_epoch(epoch => $time)
                    ->set_time_zone(&Apache::lonlocal::gettimezone());
   
  # If there's a caller supplied format, use it.   # If there's a caller supplied format, use it.
   
  if($format ne '') {   if ($format ne '') {
     my $timeStr = strftime($format, localtime($time));      my $timeStr = $dt->strftime($format);
     return $timeStr.&Apache::lonlocal::gettimezone($time);      return $timeStr.' ('.$dt->time_zone_short_name().')';
  }   }
   
         # Less than 5 days away, display day of the week and          # Less than 5 days away, display day of the week and
         # HH:MM          # HH:MM
   
         if ( $delta < $day * 5 ) {          if ( $delta < $day * 5 ) {
             my $timeStr = strftime("%A, %b %e at %I:%M %P", localtime($time));              my $timeStr = $dt->strftime("%A, %b %e at %I:%M %P (%Z)");
             $timeStr =~ s/12:00 am/00:00/;              $timeStr =~ s/12:00 am/00:00/;
             $timeStr =~ s/12:00 pm/noon/;              $timeStr =~ s/12:00 pm/noon/;
             return ($inPast ? "last " : "this ") .              return ($inPast ? "last " : "this ") .
                 $timeStr.&Apache::lonlocal::gettimezone($time);                  $timeStr;
         }          }
                   
  my $conjunction='on';   my $conjunction='on';
Line 391  sub timeToHumanString { Line 391  sub timeToHumanString {
     $conjunction='by';      $conjunction='by';
  }   }
         # Is it this year?          # Is it this year?
         if ( $time[5] == $now[5]) {   my $dt_now = DateTime->from_epoch(epoch => $now)
                        ->set_time_zone(&Apache::lonlocal::gettimezone());
           if ( $dt->year() == $dt_now->year()) {
             # Return on Month Day, HH:MM meridian              # Return on Month Day, HH:MM meridian
             my $timeStr = strftime("$conjunction %A, %b %e at %I:%M %P", localtime($time));              my $timeStr = $dt->strftime("$conjunction %A, %b %e at %I:%M %P (%Z)");
             $timeStr =~ s/12:00 am/00:00/;              $timeStr =~ s/12:00 am/00:00/;
             $timeStr =~ s/12:00 pm/noon/;              $timeStr =~ s/12:00 pm/noon/;
             return $timeStr.&Apache::lonlocal::gettimezone($time);              return $timeStr;
         }          }
   
         # Not this year, so show the year          # Not this year, so show the year
         my $timeStr = strftime("$conjunction %A, %b %e %Y at %I:%M %P", localtime($time));          my $timeStr = 
       $dt->strftime("$conjunction %A, %b %e %Y at %I:%M %P (%Z)");
         $timeStr =~ s/12:00 am/00:00/;          $timeStr =~ s/12:00 am/00:00/;
         $timeStr =~ s/12:00 pm/noon/;          $timeStr =~ s/12:00 pm/noon/;
         return $timeStr.&Apache::lonlocal::gettimezone($time);          return $timeStr;
     }      }
 }  }
   
Line 1045  my %statusStrings = Line 1048  my %statusStrings =
      );       );
 my @statuses = ($resObj->CORRECT, $resObj->ATTEMPTED, $resObj->INCORRECT, $resObj->OPEN, $resObj->CLOSED, $resObj->ERROR);  my @statuses = ($resObj->CORRECT, $resObj->ATTEMPTED, $resObj->INCORRECT, $resObj->OPEN, $resObj->CLOSED, $resObj->ERROR);
   
 use Data::Dumper;  
 sub render_parts_summary_status {  sub render_parts_summary_status {
     my ($resource, $part, $params) = @_;      my ($resource, $part, $params) = @_;
     if (!$resource->is_problem() && !$resource->contains_problem) { return '<td></td>'; }      if (!$resource->is_problem() && !$resource->contains_problem) { return '<td></td>'; }
Line 1289  sub render { Line 1291  sub render {
     # Print key?      # Print key?
     if ($printKey) {      if ($printKey) {
         $result .= '<table border="0" cellpadding="2" cellspacing="0">';          $result .= '<table border="0" cellpadding="2" cellspacing="0">';
         my $date=localtime;  
         $result.='<tr><td align="right" valign="bottom">Key:&nbsp;&nbsp;</td>';          $result.='<tr><td align="right" valign="bottom">Key:&nbsp;&nbsp;</td>';
  my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc");   my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc");
         if ($navmap->{LAST_CHECK}) {          if ($navmap->{LAST_CHECK}) {

Removed from v.1.402  
changed lines
  Added in v.1.403


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>