예제 #1
0
    static function getUTCDate($d,$h,$m,$s) {

        $jconfig = JFactory::getConfig();
        $cfg = BidsHelperTools::getConfig();

        $error_msg = array();

        $date = BidsHelperTools::auctionDatetoIso($d);

        if(!$date) {
            return false;
        }

        $hour = $minutes = '00';
        if ($cfg->bid_opt_enable_hour) {
            $hour = $h ? $h : '00';
            $minutes = $m ? $m : '00';
            if ($hour > 24 || $minutes > 60) {
                return false;
            }
        }

        $DateTime = JFactory::getDate($date . ' ' . $hour . ':' . $minutes . ':00', $jconfig->getValue('config.offset'));
        if (!$DateTime) {
            return false;
        }

        $date = BidsHelperTools::auctionDatetoIso($d);

        if ($cfg->bid_opt_enable_hour) {
            $hour = intval($h);
            if($hour<0 || $hour>59) {
                $hour = 0;
            }
            if( 1==strlen($hour) ) {
                $hour = '0'.$hour;
            }
            $minutes = intval($m);
            if($minutes<0 || $minutes>59) {
                $minutes = 0;
            }
            if( 1==strlen($minutes) ) {
                $minutes = '0'.$minutes;
            }
        } else {
            $hour = $minutes = '00';
        }

        $DateTime = JFactory::getDate($date . ' ' . $hour . ':' . $minutes . ':00', $jconfig->getValue('config.offset'));

        return ($DateTime->toUnix() < time() ) ? JFactory::getDate()->toMySQL() : $DateTime->toMySQL();
    }