Skip to content

Commit 2f6a900

Browse files
committed
- Added relative date method
1 parent 5a77963 commit 2f6a900

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lang/dv.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,7 @@
7878
"Your inputs have been saved.": "ޖެއްސެވު މަޢުލޫމާތުތައް ވަނީ ސޭވް ކުރެވިފައި",
7979
"Please verify <strong>:email</strong> to update email address to it.": "<strong>:email</strong> އަށް އީމެއިލް ބަދަލުކުރުމަށްޓަކއި އެ އީމެއިލް ވެރިފައިކުރައްވާ.",
8080
"You must verify <strong>:email</strong> to activate this account.": "މި އެކައުންޓު އެކްޓިވޭޓުކުރެއްވުމަށްޓަކައި <strong>:email</strong> އީމެއިލް ވެރިފައިކުތައްވާ.",
81-
"Resend verification email?": "އަދި އެއްފަހަރު ވެރިފިކޭޝަން އީމެއިލް ފޮނުވާ!"
81+
"Resend verification email?": "އަދި އެއްފަހަރު ވެރިފިކޭޝަން އީމެއިލް ފޮނުވާ!",
82+
":time ago": ":time ކުރިން",
83+
":time from now": "މިހާރުން ފެށިގެން އޮތް ވަޤުތު :time"
8284
}

src/helpers.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,3 +909,24 @@ function seconds_to_human_readable($seconds, bool $abbreviated = false, bool $in
909909
return implode(' ', $output);
910910
}
911911
}
912+
913+
if (! function_exists('relative_date')) {
914+
/**
915+
* Convert kb to human readable file size
916+
*
917+
* @param Carbon $date
918+
* @param null $locale
919+
* @return string
920+
*/
921+
function relative_date(Carbon $date, $locale = null) {
922+
if (! $locale) {
923+
$locale = app()->getLocale();
924+
}
925+
926+
$diff = $date->locale($locale)->longAbsoluteDiffForHumans();
927+
928+
return $date > now() ?
929+
__(':time from now', ['time' => $diff], $locale) :
930+
__(':time ago', ['time' => $diff], $locale);
931+
}
932+
}

0 commit comments

Comments
 (0)