summaryrefslogtreecommitdiffstats
path: root/application/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'application/helpers')
-rw-r--r--application/helpers/filebin_helper.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php
index ffecec98d..b89fe9bb3 100644
--- a/application/helpers/filebin_helper.php
+++ b/application/helpers/filebin_helper.php
@@ -1,5 +1,31 @@
<?php
+function expiration_duration($duration)
+{
+ $total = $duration;
+ $days = floor($total / 86400);
+ $total -= $days * 86400;
+ $hours = floor($total / 3600);
+ $total -= $hours * 3600;
+ $minutes = floor($total / 60);
+ $seconds = $total - $minutes * 60;
+ $times = array($days, $hours, $minutes, $seconds);
+ $suffixes = array(' day', ' hour', ' minute', ' second');
+ $expiration = array();
+
+ for ($i = 0; $i < count($suffixes); $i++) {
+ if ($times[$i] != 0) {
+ $duration = $times[$i].$suffixes[$i];
+ if ($times[$i] > 1) {
+ $duration .= "s";
+ }
+ array_push($expiration, $duration);
+ }
+ }
+
+ return join(", ", $expiration);
+}
+
function format_bytes($size)
{
$suffixes = array('B', 'KiB', 'MiB', 'GiB', 'TiB' , 'PiB' , 'EiB', 'ZiB', 'YiB');