From 060473d7e7da51bf372b3d2958580b8f65f4769b Mon Sep 17 00:00:00 2001 From: Minteck Date: Thu, 16 Jun 2022 11:37:18 +0200 Subject: This is the new Ember --- old/includes/functions.php | 92 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 old/includes/functions.php (limited to 'old/includes/functions.php') diff --git a/old/includes/functions.php b/old/includes/functions.php new file mode 100644 index 0000000..bef7435 --- /dev/null +++ b/old/includes/functions.php @@ -0,0 +1,92 @@ +$a.$b"; +} + +function getLetters(string $project): string { + $words = explode(" ", preg_replace('/#+/m', "#", preg_replace('/[^a-z0-9 ]/m', "#", strtolower(trim(preg_replace('/[A-Z]/m', ' $0', $project)))))); + + $words = array_slice(array_filter($words, function ($v) { + return trim($v); + }), 0); + + return substr($words[0], 0, 1); +} + +function timeAgo($time): string { + if (!is_numeric($time)) { + $time = strtotime($time); + } + + $periods = array("second", "minute", "hour", "day", "week", "month", "year", "age"); + $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); + + $now = time(); + + $difference = $now - $time; + if ($difference <= 10 && $difference >= 0) { + return $tense = 'just now'; + } elseif ($difference > 0) { + $tense = 'ago'; + } else { + $tense = 'later'; + } + + for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { + $difference /= $lengths[$j]; + } + + $difference = round($difference); + + $period = $periods[$j] . ($difference >1 ? 's' :''); + return "{$difference} {$period} {$tense} "; +} + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/Parsedown.php"; +global $Parsedown; +$Parsedown = new Parsedown(); \ No newline at end of file -- cgit