Permalink
Browse files

Trying to take into account the number of days in a month.

  • Loading branch information...
1 parent c653d83 commit 8568ac66136a95f3b519280ef099a8a8303eb294 @renan renan committed Nov 29, 2011
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/Cake/Test/Case/View/Helper/TimeHelperTest.php
@@ -126,6 +126,18 @@ public function testTimeAgoInWords() {
$seconds = 0;
$relative_date = '';
+ // Trying to take into account the number of days in a month
+ $month = date('m') - $months;
+ if ($month <= 0) {
+ $month = $months % 12;
+ }
+ $time = mktime(0, 0, 0, $month, 1, date('y') - $years);
+ $diffDays = date('t') - date('t', $time);
+
+ if ($diffDays > 0 && date('j') - date('t', $time) - $days > 0 && $months > 0 && $weeks === 0) {
+ continue;
+ }
+
if ($years > 0) {
// years and months and days
$relative_date .= ($relative_date ? ', -' : '-') . $years . ' year' . ($years > 1 ? 's' : '');

0 comments on commit 8568ac6

Please sign in to comment.