<?php
defined('BASEPATH') OR exit('No direct script access allowed');

if (!function_exists('calculate_duration')) {
    function calculate_duration($start, $end = null) {
        $start_time = new DateTime($start);
        $end_time = $end ? new DateTime($end) : new DateTime();
        
        $interval = $start_time->diff($end_time);
        
        if ($interval->days > 0) {
            return $interval->days . 'j ' . $interval->h . 'h';
        } elseif ($interval->h > 0) {
            return $interval->h . 'h ' . $interval->i . 'min';
        } else {
            return $interval->i . 'min';
        }
    }
}

if (!function_exists('format_currency')) {
    function format_currency($amount) {
        return number_format($amount, 0, ',', ' ');
    }
}
?>