[LON-CAPA-cvs] cvs: loncom(version_2_10_X) /interface lonnavmaps.pm
raeburn
raeburn at source.lon-capa.org
Fri Oct 7 11:10:12 EDT 2011
raeburn Fri Oct 7 15:10:12 2011 EDT
Modified files: (Branch: version_2_10_X)
/loncom/interface lonnavmaps.pm
Log:
- Backport 1.464.
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.444.2.5 loncom/interface/lonnavmaps.pm:1.444.2.6
--- loncom/interface/lonnavmaps.pm:1.444.2.5 Thu Sep 15 03:06:52 2011
+++ loncom/interface/lonnavmaps.pm Fri Oct 7 15:10:12 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.444.2.5 2011/09/15 03:06:52 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.444.2.6 2011/10/07 15:10:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
@@ -808,14 +808,31 @@
# Less than an hour
if ( $delta < $hour ) {
- # If so, use minutes
+ # If so, use minutes; or minutes, seconds (if format requires)
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"; }
return "$prefix$minutes minutes$tense";
}
# 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) {
my $hours = floor($delta / $hour);
my $minutes = floor(($delta % $hour) / $minute);
@@ -830,15 +847,30 @@
if ($minutes == 0) {
$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";
}
+ # Date/time is more than 24 hours away
+
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, 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);
return $timeStr.' ('.$dt->time_zone_short_name().')';
}
More information about the LON-CAPA-cvs
mailing list