• User

    aiuto con class e function

    ciao ragazzi spero proprio ke mi possiate dare 1 mano..
    in una classe ho una funzione che calcola il numero di giorni lavorativi tra 2 date
    <CODE>
    function days_diff($p_start_date, $p_end_date = NULL, $p_workdays_only = TRUE, $p_skip_holidays = TRUE){

    //
    //Function : Main function to calculate the number of days or work days between 2 dates. If no end date passed
    //           in then this can be used to identify if the day is a working day as the function will return 1 or 0
    //Params
    //         : p_start_date     This paramter is the range starting date
    //         : p_end_date       This paramter is the range ending date (can be null)
    //         : p_workdays_only  This paramter is set if you DO NOT want to count weekends
    //         : p_skip_holidays  This paramter is set if you DO NOT want to count standard Bank Holidays & enforced business shutdowns
    // Returns
    //         : number of days between the 2 dates or if no end date passed in then 1/0 if the start day is a work day
    //
    
        $end_date        = $p_end_date;
        if ( strlen($p_end_date)==0 ) $end_date = $p_start_date;
    
        $end_date        = strtotime($end_date);
        $start_date      = strtotime($p_start_date);
        $nbr_work_days   = 0;        
        for($day_val = $start_date; $day_val <= $end_date; $day_val += $this->seconds_per_day){
            $pointer_day = date("w", $day_val);
            if($p_workdays_only == true){
                if(($pointer_day != $this->sunday_val) AND ($pointer_day != $this->saturday_val)){
                    if($p_skip_holidays == true){
                        if(!in_array($day_val, $this->holiday_dates)){
                            $nbr_work_days++;
                        }
                    }else{
                        $nbr_work_days++;
                    }
                }
            }else{
                if($p_skip_holidays == true){
                    if(!in_array($day_val, $this->holiday_dates)){
                        $nbr_work_days++;
                    }
                }else{
                    $nbr_work_days++;
                }
            }
        }
        return $nbr_work_days;
    }
    

    </CODE>
    sapete dirmi com'è la funzione per calcolare qual'è il giorno lavorativo dopo tot giorni???
    tipo l'utente inserisce un giorno lavorativo ad es lunedi 18 ago e vuole sapere che giorno sarà tra 15 giorni lavorativi (risposta venerdì 5 settembre cioè quello ke dovrebbe uscire in output)
    nn so se mi sono spiegato grazie in anticipo:bigsmile: