What do you say about the following Date Function ?
What do you say about the following Date Function ?


----------


    function va_date( $mask = "", $date = "" )
    {
        global $months;
        global $short_months;
        global $weekdays;
        global $short_weekdays;
        $formated_date = "";
        if ( !is_array( $date ) )
        {
            $date = is_numeric( $date ) ? va_time( $date ) : va_time( );
        }
        if ( !is_array( $mask ) )
        {
            $mask = parse_date_format( $mask );
        }
        if ( is_array( $mask ) )
        {
            $i = 0;
            for ( ; $i < sizeof( $mask ); ++$i )
            {
                switch ( $mask[$i] )
                {
                case "YYYY" :
                    $formated_date .= $date[YEAR];
                    break;
                case "YY" :
                    $formated_date .= substr( $date[YEAR], 2 );
                    break;
                case "WWWW" :
                    $formated_date .= $weekdays[intval( date( "w", va_timestamp( $date ) ) )][1];
                    break;
                case "WWW" :
                    $formated_date .= $short_weekdays[intval( date( "w", va_timestamp( $date ) ) )][1];
                    break;
                case "MMMM" :
                    $formated_date .= $months[intval( $date[MONTH] ) - 1][1];
                    break;
                case "MMM" :
                    $formated_date .= $short_months[intval( $date[MONTH] ) - 1][1];
                    break;
                case "MM" :
                    $formated_date .= strlen( $date[MONTH] ) == 2 ? $date[MONTH] : "0".$date[MONTH];
                    break;
                case "M" :
                    $formated_date .= intval( $date[MONTH] );
                    break;
                case "DD" :
                    $formated_date .= strlen( $date[DAY] ) == 2 ? $date[DAY] : "0".$date[DAY];
                    break;
                case "D" :
                    $formated_date .= intval( $date[DAY] );
                    break;
                case "HH" :
                    $formated_date .= strlen( $date[HOUR] ) == 2 ? $date[HOUR] : "0".$date[HOUR];
                    break;
                case "H" :
                    $formated_date .= intval( $date[HOUR] );
                    break;
                case "hh" :
                    $formated_date .= get_ampmhour( $date ) == 2 ? get_ampmhour( $date ) : "0".get_ampmhour( $date );
                    break;
                case "h" :
                    $formated_date .= intval( get_ampmhour( $date ) );
                    break;
                case "mm" :
                    $formated_date .= strlen( $date[MINUTE] ) == 2 ? $date[MINUTE] : "0".$date[MINUTE];
                    break;
                case "m" :
                    $formated_date .= intval( $date[MINUTE] );
                    break;
                case "ss" :
                    $formated_date .= strlen( $date[SECOND] ) == 2 ? $date[SECOND] : "0".$date[SECOND];
                    break;
                case "s" :
                    $formated_date .= intval( $date[SECOND] );
                    break;
                case "AM" :
                    $formated_date .= get_ampm( $date );
                    break;
                case "am" :
                    $formated_date .= strtolower( get_ampm( $date ) );
                    break;
                case "GMT" :
                    $formated_date .= isset( $date[GMT] ) ? $date[GMT] : "";
                    break;
                default :
                    $formated_date .= stripslashes( $mask[$i] );
                }
            }
        }
        else
        {
            $formated_date = $date[YEAR]."-".$date[MONTH]."-".$date[DAY]." ".$date[HOUR].":".$date[MINUTE].":".$date[SECOND];
        }
        return $formated_date;
    }


----------

What do you say about the following Date Function ?
===

What do you say about the following Date Function ?


----------


    function va_date( $mask = "", $date = "" )
    {
        global $months;
        global $short_months;
        global $weekdays;
        global $short_weekdays;
        $formated_date = "";
        if ( !is_array( $date ) )
        {
            $date = is_numeric( $date ) ? va_time( $date ) : va_time( );
        }
        if ( !is_array( $mask ) )
        {
            $mask = parse_date_format( $mask );
        }
        if ( is_array( $mask ) )
        {
            $i = 0;
            for ( ; $i < sizeof( $mask ); ++$i )
            {
                switch ( $mask[$i] )
                {
                case "YYYY" :
                    $formated_date .= $date[YEAR];
                    break;
                case "YY" :
                    $formated_date .= substr( $date[YEAR], 2 );
                    break;
                case "WWWW" :
                    $formated_date .= $weekdays[intval( date( "w", va_timestamp( $date ) ) )][1];
                    break;
                case "WWW" :
                    $formated_date .= $short_weekdays[intval( date( "w", va_timestamp( $date ) ) )][1];
                    break;
                case "MMMM" :
                    $formated_date .= $months[intval( $date[MONTH] ) - 1][1];
                    break;
                case "MMM" :
                    $formated_date .= $short_months[intval( $date[MONTH] ) - 1][1];
                    break;
                case "MM" :
                    $formated_date .= strlen( $date[MONTH] ) == 2 ? $date[MONTH] : "0".$date[MONTH];
                    break;
                case "M" :
                    $formated_date .= intval( $date[MONTH] );
                    break;
                case "DD" :
                    $formated_date .= strlen( $date[DAY] ) == 2 ? $date[DAY] : "0".$date[DAY];
                    break;
                case "D" :
                    $formated_date .= intval( $date[DAY] );
                    break;
                case "HH" :
                    $formated_date .= strlen( $date[HOUR] ) == 2 ? $date[HOUR] : "0".$date[HOUR];
                    break;
                case "H" :
                    $formated_date .= intval( $date[HOUR] );
                    break;
                case "hh" :
                    $formated_date .= get_ampmhour( $date ) == 2 ? get_ampmhour( $date ) : "0".get_ampmhour( $date );
                    break;
                case "h" :
                    $formated_date .= intval( get_ampmhour( $date ) );
                    break;
                case "mm" :
                    $formated_date .= strlen( $date[MINUTE] ) == 2 ? $date[MINUTE] : "0".$date[MINUTE];
                    break;
                case "m" :
                    $formated_date .= intval( $date[MINUTE] );
                    break;
                case "ss" :
                    $formated_date .= strlen( $date[SECOND] ) == 2 ? $date[SECOND] : "0".$date[SECOND];
                    break;
                case "s" :
                    $formated_date .= intval( $date[SECOND] );
                    break;
                case "AM" :
                    $formated_date .= get_ampm( $date );
                    break;
                case "am" :
                    $formated_date .= strtolower( get_ampm( $date ) );
                    break;
                case "GMT" :
                    $formated_date .= isset( $date[GMT] ) ? $date[GMT] : "";
                    break;
                default :
                    $formated_date .= stripslashes( $mask[$i] );
                }
            }
        }
        else
        {
            $formated_date = $date[YEAR]."-".$date[MONTH]."-".$date[DAY]." ".$date[HOUR].":".$date[MINUTE].":".$date[SECOND];
        }
        return $formated_date;
    }


----------
