<commit_before><?php
    class Date_Time_Format{
        public static $user     = 'd.m.Y';
        public static $database = 'Y-m-d';
        
        public static $user_placeholder     = 'DD.MM.YYYY';
        public static $database_placeholder = 'YYYY.MM.DD';
        
        public static $friendly_date     = 'd-M-Y';
        public static $friendly_datetime = 'd-M-Y H:i:s';
        
        public static function current($format='YmdHis'){
            return date($format);
        }         

        public static function compare($date){
            if( self::current(self::$database) > date(self::$database, strtotime($date)) ){
                return true;                          
            }else{
                return false;
            }
        }
        
        public static function validate($date, $format){ 
            switch($format){
                case self::$user_placeholder:
                    $regex = '^([0-9]{2})\.([0-9]{2})\.([0-9]{4})$^';
                    break;
                case self::$database_placeholder:
                    $regex = '^([0-9]{4})-([0-9]{2})-([0-9]{2})$^';
                    break;    
                default: $regex = '';
            }
            
            if( empty($regex) ){
                return false;
            }else{
                if( preg_match($regex, $date) ){
                    return true;
                }else{
                    return false;
                }
            }
        } 
        
        public static function format($date, $withoutTime=false){
            if($withoutTime){
                return date(self::$friendly_date, strtotime($date));
            }else{
                return date(self::$friendly_datetime, strtotime($date));
            }
        } 
        
        public static function format_to_database($date){
            return date(self::$database, strtotime($date));
        } 
        
        public static function format_to_user($date, $withoutTime=false){
            return date(self::$user, strtotime($date));
        }
        
        public static function minutes_to_hours($time=0, $format='%02d:%02d'){
            if($time > 0){
                $hours = floor($time / 60);
                $minutes = ($time % 60);
                
                return sprintf($format, $hours, $minutes);
            }else{
                return '00:00';
            }
        }
        
        public static function hours_to_minutes($time){
            if (strpos($time, ':') !== false){
                $exploded = explode(':', $time);
              
                $hoursFirst = true;
                foreach($exploded as $row){
                      $number = $row;
                                              
                      if($hoursFirst){
                          $hours = $number; 
                          $hoursFirst = false;
                      }else{
                          $minutes = $number; 
                      }                           
                }               
                $minutes += $hours*60;
            }else{
                $minutes = '';  
            }
        return $minutes; 
        } 
        
        public static function number_to_month($month, $language=''){
            switch ($month){
                case 1:
                    {
                        switch($language){           
                            case 'EN': return 'january'; break;
                            default: return 'januar';
                        }
                    } break;
                case 2:
                    {
                        switch($language){           
                            case 'EN': return 'february'; break;
                            default: return 'februar';
                        }
                    } break;
                case 3:
                    {
                        switch($language){           
                            case 'EN': return 'march'; break;
                            default: return 'mart';
                        }
                    } break;
                case 4:
                    {
                        switch($language){           
                            case 'EN': return 'april'; break;
                            default: return 'april';
                        }
                    } break;
                case 5:
                    {
                        switch($language){           
                            case 'EN': return 'may'; break;
                            default: return 'maj';
                        }
                    } break;
                case 6:
                    {
                        switch($language){           
                            case 'EN': return 'june'; break;
                            default: return 'jun';
                        }
                    } break;
                case 7:
                    {
                        switch($language){           
                            case 'EN': return 'july'; break;
                            default: return 'jul';
                        }
                    } break;
                case 8:
                    {
                        switch($language){           
                            case 'EN': return 'august'; break;
                            default: return 'avgust';
                        }
                    } break;
                case 9:
                    {
                        switch($language){           
                            case 'EN': return 'september'; break;
                            default: return 'septembar';
                        }
                    } break;
                case 10:
                    {
                        switch($language){           
                            case 'EN': return 'october'; break;
                            default: return 'oktobar';
                        }
                    } break;
                case 11:
                    {
                        switch($language){           
                            case 'EN': return 'november'; break;
                            default: return 'novembar';
                        }
                    } break;
                case 12:
                    {
                        switch($language){           
                            case 'EN': return 'december'; break;
                            default: return 'decembar';
                        }
                    } break;
            }
        }
    }
?><commit_msg>Month number to month name function conversion<commit_after><?php
/**
* Date and Time formating, validating, comparing, converting...
*/
class Date_Time_Format{
    public static $user     = 'd.m.Y';
    public static $database = 'Y-m-d';
    
    public static $user_placeholder     = 'DD.MM.YYYY';
    public static $database_placeholder = 'YYYY.MM.DD';
    
    public static $friendly_date     = 'd-M-Y';
    public static $friendly_datetime = 'd-M-Y H:i:s';
    
    // -------------------------------------------------------------------------
    
    public static function current($format='YmdHis'){
        return date($format);
    }         

    // -------------------------------------------------------------------------
    
    public static function compare($date){
        if( self::current(self::$database) > date(self::$database, strtotime($date)) ){
            return true;                          
        }else{
            return false;
        }
    }
    
    // -------------------------------------------------------------------------
    
    public static function validate($date, $format){ 
        switch($format){
            case self::$user_placeholder:
                $regex = '^([0-9]{2})\.([0-9]{2})\.([0-9]{4})$^';
                break;
            case self::$database_placeholder:
                $regex = '^([0-9]{4})-([0-9]{2})-([0-9]{2})$^';
                break;    
            default: $regex = '';
        }
        
        if( empty($regex) ){
            return false;
        }else{
            if( preg_match($regex, $date) ){
                return true;
            }else{
                return false;
            }
        }
    } 
    
    // -------------------------------------------------------------------------
    
    public static function format($date, $withoutTime=false){
        if($withoutTime){
            return date(self::$friendly_date, strtotime($date));
        }else{
            return date(self::$friendly_datetime, strtotime($date));
        }
    } 
    
    // -------------------------------------------------------------------------
    
    public static function format_to_database($date){
        return date(self::$database, strtotime($date));
    } 
    
    // -------------------------------------------------------------------------
    
    public static function format_to_user($date, $withoutTime=false){
        return date(self::$user, strtotime($date));
    }
    
    // -------------------------------------------------------------------------
    
    public static function minutes_to_hours($time=0, $format='%02d:%02d'){
        if($time > 0){
            $hours = floor($time / 60);
            $minutes = ($time % 60);
            
            return sprintf($format, $hours, $minutes);
        }else{
            return '00:00';
        }
    }
    
    // -------------------------------------------------------------------------
    
    public static function hours_to_minutes($time){
        if (strpos($time, ':') !== false){
            $exploded = explode(':', $time);
          
            $hoursFirst = true;
            foreach($exploded as $row){
                  $number = $row;
                                          
                  if($hoursFirst){
                      $hours = $number; 
                      $hoursFirst = false;
                  }else{
                      $minutes = $number; 
                  }                           
            }               
            $minutes += $hours*60;
        }else{
            $minutes = '';  
        }
    return $minutes; 
    } 
    
    // -------------------------------------------------------------------------
    
    /**
    * Converts number of month to month name in specific language
    * 
    * @param int $month
    * @param String $language
    * @return String/Bool
    */
    public static function number_to_month($month, $language='')
    {
        switch($month)
        {
            case 1:
                {
                    switch($language)
                    {
                        case 'EN': return 'january'; break;
                        default: return 'januar';
                    }
                } break;
            case 2:
                {
                    switch($language)
                    {
                        case 'EN': return 'february'; break;
                        default: return 'februar';
                    }
                } break;
            case 3:
                {
                    switch($language)
                    {
                        case 'EN': return 'march'; break;
                        default: return 'mart';
                    }
                } break;
            case 4:
                {
                    switch($language)
                    {
                        case 'EN': return 'april'; break;
                        default: return 'april';
                    }
                } break;
            case 5:
                {
                    switch($language)
                    {
                        case 'EN': return 'may'; break;
                        default: return 'maj';
                    }
                } break;
            case 6:
                {
                    switch($language)
                    {
                        case 'EN': return 'june'; break;
                        default: return 'jun';
                    }
                } break;
            case 7:
                {
                    switch($language)
                    {
                        case 'EN': return 'july'; break;
                        default: return 'jul';
                    }
                } break;
            case 8:
                {
                    switch($language)
                    {
                        case 'EN': return 'august'; break;
                        default: return 'avgust';
                    }
                } break;
            case 9:
                {
                    switch($language)
                    {
                        case 'EN': return 'september'; break;
                        default: return 'septembar';
                    }
                } break;
            case 10:
                {
                    switch($language)
                    {
                        case 'EN': return 'october'; break;
                        default: return 'oktobar';
                    }
                } break;
            case 11:
                {
                    switch($language)
                    {
                        case 'EN': return 'november'; break;
                        default: return 'novembar';
                    }
                } break;
            case 12:
                {
                    switch($language)
                    {
                        case 'EN': return 'december'; break;
                        default: return 'decembar';
                    }
                } break;
            default: return FALSE;
        }
    }
    
    // -------------------------------------------------------------------------
}
?>
{'fraction_non_alphanumeric': 0.1516601420907641, 'fraction_numerical': 0.007104538205016674, 'mean_word_length': 0.7104773713577185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7560887', 'n_tokens_mistral': 3200, 'n_tokens_neox': 2921, 'n_words': 649}