Skip to content

Commit

Permalink
- Added relative date method
Browse files Browse the repository at this point in the history
  • Loading branch information
dash8x committed Nov 13, 2024
1 parent 5a77963 commit 2f6a900
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lang/dv.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@
"Your inputs have been saved.": "ޖެއްސެވު މަޢުލޫމާތުތައް ވަނީ ސޭވް ކުރެވިފައި",
"Please verify <strong>:email</strong> to update email address to it.": "<strong>:email</strong> އަށް އީމެއިލް ބަދަލުކުރުމަށްޓަކއި އެ އީމެއިލް ވެރިފައިކުރައްވާ.",
"You must verify <strong>:email</strong> to activate this account.": "މި އެކައުންޓު އެކްޓިވޭޓުކުރެއްވުމަށްޓަކައި <strong>:email</strong> އީމެއިލް ވެރިފައިކުތައްވާ.",
"Resend verification email?": "އަދި އެއްފަހަރު ވެރިފިކޭޝަން އީމެއިލް ފޮނުވާ!"
"Resend verification email?": "އަދި އެއްފަހަރު ވެރިފިކޭޝަން އީމެއިލް ފޮނުވާ!",
":time ago": ":time ކުރިން",
":time from now": "މިހާރުން ފެށިގެން އޮތް ވަޤުތު :time"
}
21 changes: 21 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,3 +909,24 @@ function seconds_to_human_readable($seconds, bool $abbreviated = false, bool $in
return implode(' ', $output);
}
}

if (! function_exists('relative_date')) {
/**
* Convert kb to human readable file size
*
* @param Carbon $date
* @param null $locale
* @return string
*/
function relative_date(Carbon $date, $locale = null) {
if (! $locale) {
$locale = app()->getLocale();
}

$diff = $date->locale($locale)->longAbsoluteDiffForHumans();

return $date > now() ?
__(':time from now', ['time' => $diff], $locale) :
__(':time ago', ['time' => $diff], $locale);
}
}

0 comments on commit 2f6a900

Please sign in to comment.