<?php
use Carbon\Carbon; 

if ( ! function_exists('db_date_time_to_carbon')){
    function db_date_time_to_carbon($db_date, $tz = 'UTC'){
        return Carbon::createFromFormat(
                "Y-m-d H:i:s", 
                $db_date, 
                new DateTimeZone($tz));     
    }
        
} 

if ( ! function_exists('db_date_to_carbon')){
    function db_date_to_carbon($db_date, $tz = 'UTC'){
        try{
            return Carbon::createFromFormat(
                "Y-m-d H:i:s", 
                $db_date . " 00:00:00", 
                new DateTimeZone($tz));
            }catch(Exception $e){
                throw new Exception($db_date,0, $e);
            }

    }
        
}  

if ( ! function_exists('format_date')) {
    function format_date($date) {
        if (is_string($date)) {
            $date = strtotime($date);
        }
        $month = Lang::get('frontend.short_month_' . date('n', $date));
        $day = date("d", $date);
        $year = date("Y", $date);
        return $day . ' ' . $month . ' ' . $year;
    }
}

if ( ! function_exists('get_month_array')) {
    function get_month_array() {
        return array(
            "01" => "January",
            "02" => "February",
            "03" => "March",
            "04" => "April",
            "05" => "May",
            "06" => "June",
            "07" => "July",
            "08" => "August",
            "09" => "September",
            "10" => "October",
            "11" => "November",
            "12" => "December");
    }
}