And restore the original method, and add tests to catch the approximation in Session/DateTime.t instead
of relying on Asset/Story.t
This commit is contained in:
parent
3c4ae9aa82
commit
9259e1db23
2 changed files with 32 additions and 16 deletions
|
|
@ -822,23 +822,39 @@ The number of seconds in the interval.
|
|||
=cut
|
||||
|
||||
sub secondsToInterval {
|
||||
my $self = shift;
|
||||
my $seconds = shift;
|
||||
my $self = shift;
|
||||
my $seconds = shift;
|
||||
my $i18n = WebGUI::International->new($self->session, 'WebGUI');
|
||||
my %units = (
|
||||
31536000 => "703", # years
|
||||
2592000 => "702", # months
|
||||
604800 => "701", # weeks
|
||||
86400 => "700", # days
|
||||
3600 => "706", # hours
|
||||
60 => "705", # minutes
|
||||
);
|
||||
for my $unit (sort { $b <=> $a } keys %units) {
|
||||
if ($seconds % $unit == 0) {
|
||||
return ($seconds / $unit, $i18n->get($units{$unit}));
|
||||
}
|
||||
my ($interval, $units);
|
||||
if ($seconds >= 31536000) {
|
||||
$interval = round($seconds/31536000);
|
||||
$units = $i18n->get("703");
|
||||
}
|
||||
elsif ($seconds >= 2592000) {
|
||||
$interval = round($seconds/2592000);
|
||||
$units = $i18n->get("702");
|
||||
}
|
||||
elsif ($seconds >= 604800) {
|
||||
$interval = round($seconds/604800);
|
||||
$units = $i18n->get("701");
|
||||
}
|
||||
elsif ($seconds >= 86400) {
|
||||
$interval = round($seconds/86400);
|
||||
$units = $i18n->get("700");
|
||||
}
|
||||
return ($seconds, $i18n->get("704")); # seconds
|
||||
elsif ($seconds >= 3600) {
|
||||
$interval = round($seconds/3600);
|
||||
$units = $i18n->get("706");
|
||||
}
|
||||
elsif ($seconds >= 60) {
|
||||
$interval = round($seconds/60);
|
||||
$units = $i18n->get("705");
|
||||
}
|
||||
else {
|
||||
$interval = $seconds;
|
||||
$units = $i18n->get("704");
|
||||
}
|
||||
return ($interval, $units);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ my $cwd = Cwd::cwd();
|
|||
|
||||
my ($extensionTests, $fileIconTests) = setupDataDrivenTests($session);
|
||||
|
||||
my $numTests = 136; # increment this value for each test you create
|
||||
my $numTests = 127; # increment this value for each test you create
|
||||
plan tests => $numTests + scalar @{ $extensionTests } + scalar @{ $fileIconTests };
|
||||
|
||||
my $uploadDir = $session->config->get('uploadsPath');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue