Diff for /loncom/interface/lonnavmaps.pm between versions 1.444.2.5 and 1.444.2.6

version 1.444.2.5, 2011/09/15 03:06:52 version 1.444.2.6, 2011/10/07 15:10:12
Line 808  sub timeToHumanString { Line 808  sub timeToHumanString {
   
         # Less than an hour          # Less than an hour
         if ( $delta < $hour ) {          if ( $delta < $hour ) {
             # If so, use minutes              # If so, use minutes; or minutes, seconds (if format requires)
             my $minutes = floor($delta / 60);              my $minutes = floor($delta / 60);
               if (($format ne '') && ($format =~ /\%(T|S)/)) {
                   my $display;
                   if ($minutes == 1) {
                       $display = "${prefix}1 minute";
                   } else {
                       $display = "$prefix$minutes minutes";
                   }
                   my $seconds = $delta % $minute;
                   if ($seconds == 0) {
                       $display .= $tense;
                   } elsif ($seconds == 1) {
                       $display .= ", 1 second$tense";
                   } else {
                       $display .= ", $seconds seconds$tense";
                   }
                   return $display;
               }
             if ($minutes == 1) { return "${prefix}1 minute$tense"; }              if ($minutes == 1) { return "${prefix}1 minute$tense"; }
             return "$prefix$minutes minutes$tense";              return "$prefix$minutes minutes$tense";
         }          }
                   
         # Is it less than 24 hours away? If so,          # Is it less than 24 hours away? If so,
         # display hours + minutes          # display hours + minutes, (and + seconds, if format specified it)
         if ( $delta < $hour * 24) {          if ( $delta < $hour * 24) {
             my $hours = floor($delta / $hour);              my $hours = floor($delta / $hour);
             my $minutes = floor(($delta % $hour) / $minute);              my $minutes = floor(($delta % $hour) / $minute);
Line 830  sub timeToHumanString { Line 847  sub timeToHumanString {
             if ($minutes == 0) {              if ($minutes == 0) {
                 $minuteString = "";                  $minuteString = "";
             }              }
               if (($format ne '') && ($format =~ /\%(T|S)/)) {
                   my $display = "$prefix$hourString$minuteString";
                   my $seconds = $delta-(($hours * $hour)+($minutes * $minute));
                   if ($seconds == 0) {
                       $display .= $tense;
                   } elsif ($seconds == 1) {
                       $display .= ", 1 second$tense";
                   } else {
                       $display .= ", $seconds seconds$tense";
                   }
                   return $display;
               }
             return "$prefix$hourString$minuteString$tense";              return "$prefix$hourString$minuteString$tense";
         }          }
   
           # Date/time is more than 24 hours away
   
  my $dt = DateTime->from_epoch(epoch => $time)   my $dt = DateTime->from_epoch(epoch => $time)
                  ->set_time_zone(&Apache::lonlocal::gettimezone());                   ->set_time_zone(&Apache::lonlocal::gettimezone());
   
  # If there's a caller supplied format, use it.   # If there's a caller supplied format, use it, unless it only displays
           # H:M:S or H:M.
   
  if ($format ne '') {          if (($format ne '') && ($format ne '%T') && ($format ne '%R')) {
     my $timeStr = $dt->strftime($format);      my $timeStr = $dt->strftime($format);
     return $timeStr.' ('.$dt->time_zone_short_name().')';      return $timeStr.' ('.$dt->time_zone_short_name().')';
  }   }

Removed from v.1.444.2.5  
changed lines
  Added in v.1.444.2.6


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