Changeset 483
- Timestamp:
- 10/16/2006 08:53:12 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/bb-includes/functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bb-includes/functions.php
r482 r483 246 246 // array of time period chunks 247 247 $chunks = array( 248 array(60 * 60 * 24 * 365 , __('year') ),249 array(60 * 60 * 24 * 30 , __('month') ),250 array(60 * 60 * 24 * 7, __('week') ),251 array(60 * 60 * 24 , __('day') ),252 array(60 * 60 , __('hour') ),253 array(60 , __('minute') ),248 array(60 * 60 * 24 * 365 , __('year') , __('years')), 249 array(60 * 60 * 24 * 30 , __('month') , __('months')), 250 array(60 * 60 * 24 * 7, __('week') , __('weeks')), 251 array(60 * 60 * 24 , __('day') , __('days')), 252 array(60 * 60 , __('hour') , __('hours')), 253 array(60 , __('minute') , __('minutes')), 254 254 ); 255 255 256 256 $today = time(); 257 257 $since = $today - bb_offset_time($original); 258 258 259 259 for ($i = 0, $j = count($chunks); $i < $j; $i++) { 260 260 $seconds = $chunks[$i][0]; 261 261 $name = $chunks[$i][1]; 262 262 $names = $chunks[$i][2]; 263 263 264 if (($count = floor($since / $seconds)) != 0) 264 265 break; 265 266 } 266 267 $print = ($count == 1) ? '1 '.$name : "$count {$name}s";268 267 268 $print = sprintf(__('%1$d %2$s'), $count, ($count == 1) ? $name : $names); 269 269 270 if ($i + 1 < $j) { 270 271 $seconds2 = $chunks[$i + 1][0]; 271 272 $name2 = $chunks[$i + 1][1]; 272 273 $names2 = $chunks[$i + 1][1]; 274 273 275 // add second item if it's greater than 0 274 276 if ( (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) && $do_more ) 275 $print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";277 $print .= sprintf(__(', %1$d %2$s'), $count2, ($count2 == 1) ? $name2 : $names2); 276 278 } 277 279 return $print;
Note: See TracChangeset
for help on using the changeset viewer.