diff --git a/src/Date.php b/src/Date.php index 449948b..13f09a1 100644 --- a/src/Date.php +++ b/src/Date.php @@ -98,87 +98,6 @@ public static function createFromFormat($format, $time, $timezone = null) return parent::createFromFormat($format, $time, $timezone); } - /** - * @inheritdoc - */ - public function diffForHumans(Carbon $since = null, $absolute = false, $short = false) - { - // Are we comparing against another date? - $relative = ! is_null($since); - - if (is_null($since)) { - $since = new static('now', $this->getTimezone()); - } - - // Are we comparing to a date in the future? - $future = $since->getTimestamp() < $this->getTimestamp(); - - // Calculate difference between the 2 dates. - $diff = $this->diff($since); - - switch (true) { - case $diff->y > 0: - $unit = $short ? 'y' : 'year'; - $count = $diff->y; - break; - case $diff->m > 0: - $unit = $short ? 'm' : 'month'; - $count = $diff->m; - break; - case $diff->d > 0: - $unit = $short ? 'd' : 'day'; - $count = $diff->d; - if ($count >= static::DAYS_PER_WEEK) { - $unit = $short ? 'w' : 'week'; - $count = (int) ($count / static::DAYS_PER_WEEK); - } - break; - case $diff->h > 0: - $unit = $short ? 'h' : 'hour'; - $count = $diff->h; - break; - case $diff->i > 0: - $unit = $short ? 'min' : 'minute'; - $count = $diff->i; - break; - default: - $count = $diff->s; - $unit = $short ? 's' : 'second'; - break; - } - - if ($count === 0) { - $count = 1; - } - - // Select the suffix. - if ($relative) { - $suffix = $future ? 'after' : 'before'; - } else { - $suffix = $future ? 'from_now' : 'ago'; - } - - // Get translator instance. - $lang = $this->getTranslator(); - - // Some languages have different unit translations when used in combination - // with a specific suffix. Here we will check if there is an optional - // translation for that specific suffix and use it if it exists. - if ($lang->trans("${unit}_diff") != "${unit}_diff") { - $ago = $lang->transChoice("${unit}_diff", $count, [':count' => $count]); - } elseif ($lang->trans("${unit}_${suffix}") != "${unit}_${suffix}") { - $ago = $lang->transChoice("${unit}_${suffix}", $count, [':count' => $count]); - } else { - $ago = $lang->transChoice($unit, $count, [':count' => $count]); - } - - if ($absolute) { - return $ago; - } - - return $lang->transChoice($suffix, $count, [':time' => $ago]); - } - /** * Alias for diffForHumans. * diff --git a/src/Lang/de.php b/src/Lang/de.php index 8cae7ae..e58637d 100644 --- a/src/Lang/de.php +++ b/src/Lang/de.php @@ -66,12 +66,13 @@ 'sat' => 'Sa', 'sun' => 'So', - 'year_diff' => '1 Jahr|:count Jahren', - 'month_diff' => '1 Monat|:count Monaten', - 'week_diff' => '1 Woche|:count Wochen', - 'day_diff' => '1 Tag|:count Tagen', - 'hour_diff' => '1 Stunde|:count Stunden', - 'minute_diff' => '1 Minute|:count Minuten', - 'second_diff' => '1 Sekunde|:count Sekunden', + 'year_from_now' => '1 Jahr|:count Jahren', + 'month_from_now' => '1 Monat|:count Monaten', + 'week_from_now' => '1 Woche|:count Wochen', + 'day_from_now' => '1 Tag|:count Tagen', + 'year_ago' => '1 Jahr|:count Jahren', + 'month_ago' => '1 Monat|:count Monaten', + 'week_ago' => '1 Woche|:count Wochen', + 'day_ago' => '1 Tag|:count Tagen', ]; diff --git a/src/Lang/ta.php b/src/Lang/ta.php index f55c285..458984a 100644 --- a/src/Lang/ta.php +++ b/src/Lang/ta.php @@ -13,7 +13,7 @@ */ 'ago' => ':time முன்பு', - 'from_now' => ':time|:time', + 'from_now' => ':time', 'after' => ':time கழித்து', 'before' => ':time முன்னால்', 'year' => '1 ஆண்டு|:count ஆண்டுகள்', @@ -58,12 +58,12 @@ 'month_ago' => '1 மாதம்|:count மாதங்களுக்கு', 'year_ago' => '1 ஆண்டு|:count ஆண்டுகளுக்கு', - 'second_from_now' => ':count வினாடியில்|:count வினாடிகளில்', - 'minute_from_now' => ':count நிமிடத்தில்|:count நிமிடங்களில்', - 'hour_from_now' => ':count மணி நேரத்தில்|:count மணி நேரத்தில்', - 'day_from_now' => ':count நாளில்|:count நாட்களில்', - 'week_from_now' => ':count வாரத்தில்|:count வாரங்களில்', - 'month_from_now' => ':count மாதத்தில்|:count மாதங்களில்', - 'year_from_now' => ':count ஆண்டில்|:count ஆண்டுகளில்' + 'second_from_now' => '1 வினாடியில்|:count வினாடிகளில்', + 'minute_from_now' => '1 நிமிடத்தில்|:count நிமிடங்களில்', + 'hour_from_now' => '1 மணி நேரத்தில்|:count மணி நேரத்தில்', + 'day_from_now' => '1 நாளில்|:count நாட்களில்', + 'week_from_now' => '1 வாரத்தில்|:count வாரங்களில்', + 'month_from_now' => '1 மாதத்தில்|:count மாதங்களில்', + 'year_from_now' => '1 ஆண்டில்|:count ஆண்டுகளில்' ];