Development

Changeset 8763

You must first sign up to be able to contribute.

Changeset 8763

Show
Ignore:
Timestamp:
05/04/08 09:24:40 (5 months ago)
Author:
fabien
Message:

fixed DateHelper? distance_of_time_in_words() generates incorrect output for some dates (closes #3322)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/lib/helper/DateHelper.php

    r3815 r8763  
    149149  { 
    150150    $string = 'over %years% years'; 
    151     $parameters['%years%'] = round($distance_in_minutes / 525960); 
     151    $parameters['%years%'] = floor($distance_in_minutes / 525960); 
    152152  } 
    153153 
  • branches/1.0/test/unit/helper/DateHelperTest.php

    r3167 r8763  
    1313sfLoader::loadHelpers(array('Helper', 'Asset', 'Url', 'Tag', 'Date')); 
    1414 
    15 $t = new lime_test(493, new lime_output_color()); 
     15$t = new lime_test(494, new lime_output_color()); 
    1616 
    1717class sfContext 
     
    2020  public static $instance = null; 
    2121 
    22   public function getInstance() 
     22  static public function getInstance() 
    2323  { 
    2424    if (!isset(self::$instance)) 
     
    8181 
    8282$t->is(distance_of_time_in_words($now - 370 * 86400, $now), 'about 1 year', $msg); 
    83 $t->is(distance_of_time_in_words($now - 4 * 365 * 86400, $now), 'over 4 years', $msg); 
     83$t->is(distance_of_time_in_words($now - 4 * 370 * 86400, $now), 'over 4 years', $msg); 
     84$t->is(distance_of_time_in_words($now - 1000 * 86400, $now), 'over 2 years', $msg); 
    8485 
    8586// format_date()