当前位置: 首页>>代码示例>>PHP>>正文


PHP days_in_month函数代码示例

本文整理汇总了PHP中days_in_month函数的典型用法代码示例。如果您正苦于以下问题:PHP days_in_month函数的具体用法?PHP days_in_month怎么用?PHP days_in_month使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了days_in_month函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPastDates

function getPastDates($number)
{
    $datestring = "%d-%m-%Y";
    $time = time();
    $datestring = mdate($datestring, $time);
    $splitted_date = explode("-", $datestring);
    $year = (int) $splitted_date[2];
    $month = (int) $splitted_date[1];
    $day = (int) $splitted_date[0];
    $dates = array();
    foreach ($programs as $key => $value) {
        $ordByProg[$value] = 0;
    }
    $dates[$day . '-' . $month . '-' . $year] = $ordByProg;
    for ($i = 0; $i < $number - 1; $i++) {
        if ($day - 1 > 0) {
            $day = $day - 1;
            $dates[$day . '-' . $month . '-' . $year] = '';
        } else {
            if ($month - 1 > 0) {
                $month = $month - 1;
                $day = days_in_month($month, $year);
            } else {
                $month = 12;
                $year = $year - 1;
                $day = days_in_month($month, $year);
            }
            $dates[$day . '-' . $month . '-' . $year] = '';
        }
    }
    return array_reverse($dates);
}
开发者ID:kumarsivarajan,项目名称:cse300-group10,代码行数:32,代码来源:MY_date_helper.php

示例2: filter

 function filter($condition = FALSE)
 {
     $days_in_this_month = days_in_month(date('m'), date('Y'));
     $lastday_in_month = date('Y') . "-" . date('m') . "-" . $days_in_this_month;
     $firstday_in_month = date('Y') . "-" . date('m') . "-01";
     $this->view_data['estimates_paid_this_month'] = Invoice::count(array('conditions' => 'paid_date <= ' . $lastday_in_month . ' and paid_date >= ' . $firstday_in_month . ' AND estimate != 0'));
     $this->view_data['estimates_due_this_month'] = Invoice::count(array('conditions' => 'due_date <= ' . $lastday_in_month . ' and due_date >= ' . $firstday_in_month . ' AND estimate != 0'));
     switch ($condition) {
         case 'open':
             $this->view_data['estimates'] = Invoice::find('all', array('conditions' => array('estimate_status = ? and estimate != ?', 'Open', 0)));
             break;
         case 'sent':
             $this->view_data['estimates'] = Invoice::find('all', array('conditions' => array('estimate_status = ? and estimate != ?', 'Sent', 0)));
             break;
         case 'accepted':
             $this->view_data['estimates'] = Invoice::find('all', array('conditions' => array('estimate_status = ? and estimate != ?', 'Accepted', 0)));
             break;
         case 'declined':
             $this->view_data['estimates'] = Invoice::find('all', array('conditions' => array('estimate_status = ? and estimate != ?', 'Declined', 0)));
             break;
         case 'invoiced':
             $this->view_data['estimates'] = Invoice::find('all', array('conditions' => array('estimate_status = ? and estimate != ?', 'Invoiced', 0)));
             break;
         default:
             $this->view_data['estimates'] = Invoice::find('all', array('conditions' => array('estimate != ?', 0)));
             break;
     }
     $this->content_view = 'estimates/all';
 }
开发者ID:timclifford,项目名称:freelance-manager,代码行数:29,代码来源:estimates.php

示例3: get_visits_stats

 /**
  * Get visits by chosen month.
  * @param  int $month Month
  * @return array
  */
 public function get_visits_stats($month, $format = true)
 {
     $this->load->helper('date');
     // First get total visits by date from database
     $this->db->where('MONTH(date)', $month);
     $this->db->group_by('DAY(date)');
     $this->db->select('date, COUNT(*) AS total');
     $result = $this->db->get('site_views')->result();
     // Set starting variables
     $monthStartDay = date('Y-' . $month . '-01');
     $numberOfDaysInMonth = days_in_month($month);
     // Fill all dates with zero views
     $range = array();
     for ($i = 0; $i <= $numberOfDaysInMonth; $i++) {
         $dateIncrement = date("Y-m-d", strtotime($monthStartDay . " +" . $i . " day"));
         $range[$dateIncrement] = 0;
     }
     // Remove starting day of next month
     array_pop($range);
     // Fill dates with real values
     foreach ($result as $visit) {
         $formatDate = date('Y-m-d', strtotime($visit->date));
         $range[$formatDate] = $visit->total;
     }
     if ($format) {
         return $this->format_js_data($range);
     } else {
         return $range;
     }
 }
开发者ID:karlomikus,项目名称:CometCI,代码行数:35,代码来源:comet_m.php

示例4: add_month_to_unix_time

 function add_month_to_unix_time($unix_time = 0, $multiply = 1)
 {
     if ($unix_time <= 0) {
         $unix_time = now();
     }
     $month = date('n', $unix_time);
     return $unix_time + 86400 * days_in_month($month) * $multiply;
 }
开发者ID:mefisto2009,项目名称:GameAP,代码行数:8,代码来源:date_helper.php

示例5: genehotel

 static function genehotel($mes)
 {
     $CI =& get_instance();
     $udia = days_in_month(substr($mes, 4), substr($mes, 0, 4));
     $fdesde = $mes . '01';
     $fhasta = $mes . $udia;
     // BORRA LA GENERADA ANTERIOR
     $CI->db->simple_query("DELETE FROM siva WHERE EXTRACT(YEAR_MONTH FROM fechal) = {$mes} AND fuente='FH' ");
     // ARREGLA LAS TASAS NULAS EN SFAC
     $CI->db->simple_query("UPDATE hfac SET tasa=0, montasa=0, reducida=0, monredu=0, sobretasa=0, monadic=0, exento=0 WHERE (tasa IS NULL OR montasa IS NULL) AND EXTRACT(YEAR_MONTH FROM fecha)={$mes} ");
     $mSQL = "INSERT INTO siva\n\t\t\t(id, libro, tipo, fuente, sucursal, fecha, numero, numhasta,  caja, nfiscal,  nhfiscal,\n\t\t\treferen, planilla, clipro, nombre, contribu, rif, registro,\n\t\t\tnacional, exento, general, geneimpu,\n\t\t\tadicional, adicimpu,  reducida,  reduimpu, stotal, impuesto,\n\t\t\tgtotal, reiva, fechal, fafecta)\n\t\t\tSELECT 0 AS id,\n\t\t\t'V' AS libro,\n\t\t\tIF(a.tipo='D','NC',IF(a.tipo='F','FC',CONCAT('F',a.tipo))) AS tipo,\n\t\t\t'FH' AS fuente,\n\t\t\t'00' AS sucursal,\n\t\t\ta.fecha_ou,\n\t\t\ta.num_fac,\n\t\t\t' ' AS numhasta,\n\t\t\t' ' AS caja,\n\t\t\t' ' AS nfiscal,\n\t\t\t'  ' AS nhfiscal,\n\t\t\tIF(a.tipo='E',a.num_fac,a.num_fac ) AS referen,\n\t\t\t'  ' AS planilla,\n\t\t\ta.cod_cli AS clipro,\n\t\t\tIF(a.tipo='X','DOCUMENTO ANULADO.......',if(c.nombre='',a.nombre,c.nombre)),\n\t\t\tIF(c.tiva='C','CO','NO') AS contribu,\n\t\t\tIF(c.rifci='', a.cedula, c.rifci ),\n\t\t\t'01' AS registro,\n\t\t\t'S' AS nacional,\n\t\t\t0   AS exento,\n\t\t\ta.total*(a.tipo<>'X') AS general,\n\t\t\ta.iva*(a.tipo<>'X') AS geneimpu,\n\t\t\t0 AS adicional,\n\t\t\t0 AS adicimpu,\n\t\t\t0 AS reducida,\n\t\t\t0 AS reduimpu,\n\t\t\ta.total*(a.tipo<>'X') AS stotal,\n\t\t\ta.iva*(a.tipo<>'X')    AS impuesto,\n\t\t\ta.totalg*(a.tipo<>'X') AS gtotal,\n\t\t\t0 AS reiva,\n\t\t\t" . $mes . "01 AS fechal,\n\t\t\t0 AS fafecta\n\t\t\tFROM hfac AS a\n\t\t\tLEFT JOIN scli AS c ON a.cod_cli=c.cliente\n\t\t\tWHERE a.fecha_ou BETWEEN {$fdesde} AND {$fhasta} AND a.tipo NOT IN ('P','T')";
     $flag = $CI->db->simple_query($mSQL);
     if (!$flag) {
         memowrite($mSQL, 'genehotel');
     }
     //CARGA LAS RETENCIONES DE IVA DE CONTADO
     $mSQL = "SELECT * FROM sfpa WHERE tipo='RI' AND\tf_factura BETWEEN {$fdesde} AND {$fhasta} AND tipo_doc='FE' ";
     $query = $CI->db->query($mSQL);
     if ($query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             $mSQL = "UPDATE siva SET reiva=" . $row->monto . ", comprobante='20" . $row->num_ref . "' WHERE tipo='" . $row->tipo_doc . "' AND numero='" . $row->numero . "' AND libro='V' AND fechal BETWEEN {$fdesde} AND {$fhasta} ";
             $flag = $CI->db->simple_query($mSQL);
             if (!$flag) {
                 memowrite($mSQL, 'genehotel');
             }
         }
     }
     //CARGA LAS RETENCIONES DE IVA DESDE SMOV
     $mSQL = "SELECT a.tipo_doc, a.fecha, a.numero, c.nombre, c.rifci, a.cod_cli, b.monto,\n\t\t\t\ta.numero AS afecta, a.fecha AS fafecta, a.reteiva, a.transac, a.nroriva, a.emiriva, a.recriva\n\t\t\tFROM itccli AS a JOIN smov AS b ON a.transac=b.transac\n\t\t\t\tLEFT JOIN scli AS c ON a.cod_cli=c.cliente\n\t\t\tWHERE b.fecha BETWEEN {$fdesde} AND {$fhasta} AND b.cod_cli='REIVA'\n\t\t\t\tAND a.reteiva>0 AND b.monto>b.abonos ";
     $query = $CI->db->query($mSQL);
     if ($query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             $mSQL = "UPDATE siva SET reiva=" . $row->reteiva . ", comprobante='" . $row->nroriva . "', fecharece='{$row->recriva}'  WHERE tipo='" . $row->tipo_doc . "' AND numero='" . $row->numero . "' AND libro='V' AND fechal BETWEEN {$fdesde} AND {$fhasta} ";
             $flag = $CI->db->simple_query($mSQL);
             if (!$flag) {
                 memowrite($mSQL, 'genehotel');
             }
         }
     }
 }
开发者ID:codethics,项目名称:proteoerp,代码行数:40,代码来源:hoteleria.php

示例6: filter

 function filter($userid = FALSE, $year = FALSE, $month = FALSE)
 {
     $this->view_data['userlist'] = User::find('all', array('conditions' => array('status = ?', 'active')));
     $this->view_data['username'] = User::find_by_id($userid);
     $this->view_data['user_id'] = $userid;
     $this->view_data['year'] = $year;
     $this->view_data['month'] = $month;
     $search = "";
     $stats_search = "";
     if ($userid) {
         $search .= "user_id = {$userid} and ";
         $stats_search = " AND user_id = {$userid} ";
     }
     if ($month && $year) {
         $search .= "date >= '{$year}-{$month}-01' and date <= '{$year}-{$month}-31'";
     } else {
         $search .= "date >= '{$year}-01-01' and date <= '{$year}-12-31'";
     }
     //statistic
     $graph_month = $month != 0 ? $month : date('m');
     if ($month == 0) {
         $lastday_in_month = strtotime($year . "-12-31");
         $firstday_in_month = strtotime($year . "-01-01");
         $this->view_data['days_in_this_month'] = 12;
         $this->view_data['expenses_this_month'] = Expense::count(array('conditions' => 'UNIX_TIMESTAMP(`date`) <= ' . $lastday_in_month . ' and UNIX_TIMESTAMP(`date`) >= ' . $firstday_in_month . $stats_search));
         $this->view_data['expenses_owed_this_month'] = Expense::find_by_sql('select sum(value) AS "owed" from expenses where UNIX_TIMESTAMP(`date`) >= "' . $firstday_in_month . '" AND UNIX_TIMESTAMP(`date`) <= "' . $lastday_in_month . '"' . $stats_search);
         $this->view_data['expenses_due_this_month_graph'] = Expense::find_by_sql('select sum(value) AS "owed", MONTH(`date`) as `date` from expenses where UNIX_TIMESTAMP(`date`) >= "' . $firstday_in_month . '" AND UNIX_TIMESTAMP(`date`) <= "' . $lastday_in_month . '"' . $stats_search . ' Group By MONTH(`date`)');
     } else {
         $days_in_this_month = days_in_month($graph_month, $year);
         $lastday_in_month = strtotime($year . "-" . $graph_month . "-" . $days_in_this_month);
         $firstday_in_month = strtotime($year . "-" . $graph_month . "-01");
         $this->view_data['days_in_this_month'] = $days_in_this_month;
         $this->view_data['expenses_this_month'] = Expense::count(array('conditions' => 'UNIX_TIMESTAMP(`date`) <= ' . $lastday_in_month . ' and UNIX_TIMESTAMP(`date`) >= ' . $firstday_in_month . $stats_search));
         $this->view_data['expenses_owed_this_month'] = Expense::find_by_sql('select sum(value) AS "owed" from expenses where UNIX_TIMESTAMP(`date`) >= "' . $firstday_in_month . '" AND UNIX_TIMESTAMP(`date`) <= "' . $lastday_in_month . '"' . $stats_search);
         $this->view_data['expenses_due_this_month_graph'] = Expense::find_by_sql('select sum(value) AS "owed", `date` from expenses where UNIX_TIMESTAMP(`date`) >= "' . $firstday_in_month . '" AND UNIX_TIMESTAMP(`date`) <= "' . $lastday_in_month . '"' . $stats_search . ' Group By `date`');
     }
     $this->view_data['expenses'] = Expense::find('all', array('conditions' => array("{$search}")));
     $this->content_view = 'expenses/all';
 }
开发者ID:imranweb7,项目名称:msitc-erp,代码行数:39,代码来源:expenses.php

示例7: filter

 function filter($condition = FALSE)
 {
     $days_in_this_month = days_in_month(date('m'), date('Y'));
     $lastday_in_month = date('Y') . "-" . date('m') . "-" . $days_in_this_month;
     $firstday_in_month = date('Y') . "-" . date('m') . "-01";
     $this->view_data['invoices_paid_this_month'] = Invoice::count(array('conditions' => 'paid_date <= ' . $lastday_in_month . ' and paid_date >= ' . $firstday_in_month . ''));
     $this->view_data['invoices_due_this_month'] = Invoice::count(array('conditions' => 'due_date <= ' . $lastday_in_month . ' and due_date >= ' . $firstday_in_month . ''));
     switch ($condition) {
         case 'open':
             $this->view_data['invoices'] = Invoice::find('all', array('conditions' => array('status = ?', 'Open')));
             break;
         case 'sent':
             $this->view_data['invoices'] = Invoice::find('all', array('conditions' => array('status = ?', 'Sent')));
             break;
         case 'paid':
             $this->view_data['invoices'] = Invoice::find('all', array('conditions' => array('status = ?', 'Paid')));
             break;
         default:
             $this->view_data['invoices'] = Invoice::all();
             break;
     }
     $this->content_view = 'invoices/all';
 }
开发者ID:pratikbgit,项目名称:freelancerKit,代码行数:23,代码来源:invoices.php

示例8: date_helper

 public function date_helper()
 {
     $this->load->helper('date');
     // echo mdate("%M %d %Y - %H:%i%a", time());				# Prints Current date and time. e.g: Aug 03 2015 - 03:10am
     // echo unix_to_human(time()); 								# e.g: 2015-08-03 03:21 AM
     // echo nice_date(unix_to_human(time()), 'M d Y, G:ia');	# e.g: Aug 03 2015, 3:50am
     echo "<h3>Hello, this is the date helper.</h3>";
     /**
      *	The timespan() function is very useful when you want to calculate the span of time.
      *	Or in other words, you want to calculate how many years, months, weeks, hours and minutes have passed since a particular time until to a specific time.
      **/
     $past = '1079621429';
     # This is dated: March 18, 2004 at 03:50PM
     $present = time();
     # This is the time right now
     $units = 3;
     # This will limit the information to display, max is 5.
     echo '<p>', timespan($past, $present, $units), '</p>';
     /**
      *	When we want to know how many number of days does a month have, we often make mistakes.
      *	And that is because of leap year and non-leap years.
      *	So this function, days_in_month() will help us.
      **/
     $month = 06;
     $year = 2005;
     echo '<p>' . days_in_month($month, $year) . ' days.</p>';
 }
开发者ID:eminence43rd,项目名称:ci,代码行数:27,代码来源:Main.php

示例9: find_day_in_month

function find_day_in_month($startday, $weekday, $month, $year)
{
    $daysinmonth = days_in_month($month, $year);
    if ($weekday == -1) {
        // Don't care about weekday, so return:
        //    abs($startday) if $startday != -1
        //    $daysinmonth otherwise
        return $startday == -1 ? $daysinmonth : abs($startday);
    }
    // From now on we 're looking for a specific weekday
    // Give "end of month" its actual value, since we know it
    if ($startday == -1) {
        $startday = -1 * $daysinmonth;
    }
    // Starting from day $startday, the sign is the direction
    if ($startday < 1) {
        $startday = abs($startday);
        $lastmonthweekday = strftime('%w', mktime(12, 0, 0, $month, $daysinmonth, $year, 0));
        // This is the last such weekday of the month
        $lastinmonth = $daysinmonth + $weekday - $lastmonthweekday;
        if ($lastinmonth > $daysinmonth) {
            $lastinmonth -= 7;
        }
        // Find the first such weekday <= $startday
        while ($lastinmonth > $startday) {
            $lastinmonth -= 7;
        }
        return $lastinmonth;
    } else {
        $indexweekday = strftime('%w', mktime(12, 0, 0, $month, $startday, $year, 0));
        $diff = $weekday - $indexweekday;
        if ($diff < 0) {
            $diff += 7;
        }
        // This is the first such weekday of the month equal to or after $startday
        $firstfromindex = $startday + $diff;
        return $firstfromindex;
    }
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:39,代码来源:moodlelib.php

示例10: _register_member

 /**
  * Register Member
  *
  * Create a member profile
  *
  * @return	mixed
  */
 public function _register_member()
 {
     $this->load->helper('security');
     $data = array();
     if ($this->input->post('group_id')) {
         if (!$this->cp->allowed_group('can_admin_mbr_groups')) {
             show_error(lang('unauthorized_access'));
         }
         $data['group_id'] = $this->input->post('group_id');
     }
     // -------------------------------------------
     // 'cp_members_member_create_start' hook.
     //  - Take over member creation when done through the CP
     //  - Added 1.4.2
     //
     $this->extensions->call('cp_members_member_create_start');
     if ($this->extensions->end_script === TRUE) {
         return;
     }
     //
     // -------------------------------------------
     // If the screen name field is empty, we'll assign is
     // from the username field.
     $data['screen_name'] = $this->input->post('screen_name') ? $this->input->post('screen_name') : $this->input->post('username');
     // Get the password information from Auth
     $this->load->library('auth');
     $hashed_password = $this->auth->hash_password($this->input->post('password'));
     // Assign the query data
     $data['username'] = $this->input->post('username');
     $data['password'] = $hashed_password['password'];
     $data['salt'] = $hashed_password['salt'];
     $data['unique_id'] = random_string('encrypt');
     $data['crypt_key'] = $this->functions->random('encrypt', 16);
     $data['email'] = $this->input->post('email');
     $data['ip_address'] = $this->input->ip_address();
     $data['join_date'] = $this->localize->now;
     $data['language'] = $this->config->item('deft_lang');
     $data['timezone'] = $this->config->item('default_site_timezone');
     $data['date_format'] = $this->config->item('date_format') ? $this->config->item('date_format') : '%n/%j/%y';
     $data['time_format'] = $this->config->item('time_format') ? $this->config->item('time_format') : '12';
     $data['include_seconds'] = $this->config->item('include_seconds') ? $this->config->item('include_seconds') : 'n';
     // Was a member group ID submitted?
     $data['group_id'] = !$this->input->post('group_id') ? 2 : $_POST['group_id'];
     $base_fields = array('bday_y', 'bday_m', 'bday_d', 'url', 'location', 'occupation', 'interests', 'aol_im', 'icq', 'yahoo_im', 'msn_im', 'bio');
     foreach ($base_fields as $val) {
         $data[$val] = $this->input->post($val) === FALSE ? '' : $this->input->post($val, TRUE);
     }
     if (is_numeric($data['bday_d']) && is_numeric($data['bday_m'])) {
         $this->load->helper('date');
         $year = $data['bday_y'] != '' ? $data['bday_y'] : date('Y');
         $mdays = days_in_month($data['bday_m'], $year);
         if ($data['bday_d'] > $mdays) {
             $data['bday_d'] = $mdays;
         }
     }
     // Clear out invalid values for strict mode
     foreach (array('bday_y', 'bday_m', 'bday_d') as $val) {
         if ($data[$val] == '') {
             unset($data[$val]);
         }
     }
     if ($data['url'] == 'http://') {
         $data['url'] = '';
     }
     // Extended profile fields
     $cust_fields = FALSE;
     $query = $this->member_model->get_all_member_fields(array(array('m_field_cp_reg' => 'y')), FALSE);
     if ($query->num_rows() > 0) {
         foreach ($query->result_array() as $row) {
             if ($this->input->post('m_field_id_' . $row['m_field_id']) !== FALSE) {
                 $cust_fields['m_field_id_' . $row['m_field_id']] = $this->input->post('m_field_id_' . $row['m_field_id'], TRUE);
             }
         }
     }
     $member_id = $this->member_model->create_member($data, $cust_fields);
     // Write log file
     $message = lang('new_member_added');
     $this->logger->log_action($message . NBS . NBS . stripslashes($data['username']));
     // -------------------------------------------
     // 'cp_members_member_create' hook.
     //  - Additional processing when a member is created through the CP
     //
     $this->extensions->call('cp_members_member_create', $member_id, $data);
     if ($this->extensions->end_script === TRUE) {
         return;
     }
     //
     // -------------------------------------------
     // Update Stats
     $this->stats->update_member_stats();
     $this->session->set_flashdata(array('message_success' => $message . NBS . '<b>' . stripslashes($data['username']) . '</b>', 'username' => stripslashes($data['screen_name'])));
     $this->functions->redirect(BASE . AMP . 'C=members' . AMP . 'M=view_all_members');
 }
开发者ID:kentonquatman,项目名称:canyonwoodridge,代码行数:100,代码来源:members.php

示例11: get_calendar

 public function get_calendar($calendar, $reload_url, $focus = null)
 {
     /* BENCHMARK */
     $this->benchmark->mark('func_get_calendar_start');
     $this->load->helper('data_helper');
     $this->load->model('slider_model');
     // default focus if not set
     if (null == $focus) {
         $focus = date('m-Y', time());
     }
     // get event array
     $events = json_decode($calendar['event_json'], true);
     // event nodes
     $event_nodes = $this->node_model->get_nodes(array('event.calendar_id' => $calendar['node_id'], 'type' => 'event'), 1);
     $this->event_nodes = $this->node_model->nodes_by_id($event_nodes);
     // set calendar into object and user, event default, colours etc
     $this->calendar = $calendar;
     $this->calendar['user'] = $this->node_model->get_node($this->calendar['user_id'], 'user');
     $event_default = $this->config->item('event_default');
     $this->colours = $event_default['colours'];
     // now
     $this->now = get_now();
     // break date
     $fdate_bits = date_bits($focus, '-');
     // get focus day and start of chunk
     $limit = array();
     if (is_numeric($focus)) {
         $cgran = 'year';
         $focus .= "0101";
         $limit['start'] = $focus;
         $sel_year = substr($limit['start'], 0, 4);
         $limit['end'] = $sel_year . "1232";
         // one day more than December this year will ensure only this year is output
     } elseif (8 == strlen($focus) or 7 == strlen($focus)) {
         $cgran = 'month';
         $month = is_numeric($fdate_bits[0]) ? $fdate_bits[0] : $this->month_names[strtolower($fdate_bits[0])];
         $focus = $fdate_bits[1] . $month . "01";
         $limit['start'] = $focus;
         $limit['end'] = substr($limit['start'], 0, 6) . "32";
         // one day more than any month will ensure only this month is output
     } elseif (10 == strlen($focus) or 11 == strlen($focus)) {
         $cgran = 'day';
         $month = is_numeric($fdate_bits[1]) ? $fdate_bits[1] : $this->month_names[strtolower($fdate_bits[1])];
         $focus = $fdate_bits[2] . $month . $fdate_bits[0];
         $limit['start'] = $focus;
         $limit['end'] = $limit['start'];
     } else {
         $cgran = 'month';
         $focus = str_replace('-', '', $this->now['string']);
         $limit['start'] = substr($focus, 0, 6) . "01";
         $limit['end'] = substr($focus, 0, 6) . "32";
         // one day more than any month will ensure only this month is output
     }
     // open the calendar
     $cale = '';
     $cal['meta_data'] = $calendar;
     $cal['granularity'] = $cgran;
     // back links
     $cal['back_links'] = array();
     if ('month' == $cgran) {
         // get bits
         $yf = $fdate_bits[1];
         // granularity links
         $cal['back_links']['year'] = "/" . $reload_url . "/" . $yf;
     } elseif ('day' == $cgran) {
         // get bits
         $yf = $fdate_bits[2];
         $mf = $fdate_bits[1] . '-' . $fdate_bits[2];
         // granularity links
         $cal['back_links']['year'] = "/" . $reload_url . "/" . $yf;
         $cal['back_links']['month'] = "/" . $reload_url . "/" . $mf;
     }
     // end limit
     // open the main calendar div
     // scroller
     // next and previous links
     $cal['next'] = array();
     $cal['previous'] = array();
     if ('day' == $cgran) {
         // open calendar
         $cale .= "<div id='day_chunk'>";
         // next and previous
         $y = substr($limit['start'], 0, 4);
         $m = substr($limit['start'], 4, 2);
         $d = substr($limit['start'], 6, 2);
         if ('01' == $d && '01' == $m) {
             $n = '02-01-' . $y;
             $l = '31-12-' . ($y - 1);
         } elseif ('31' == $d && '12' == $m) {
             $n = '01-01-' . ($y + 1);
             $l = '30-12-' . $y;
         } else {
             if ('01' == $d) {
                 $lm = $m - 1;
                 if ($lm < 10 ? $lm = '0' . $lm : ($lm = $lm)) {
                 }
                 $n = '02-' . $m . '-' . $y;
                 $l = days_in_month($m - 1, $y) . '-' . $lm . '-' . $y;
             } elseif ($d == days_in_month($m, $y)) {
                 $nm = $m + 1;
//.........这里部分代码省略.........
开发者ID:toni-leigh,项目名称:core,代码行数:101,代码来源:events_model.php

示例12: find_day_in_month

/**
 * Calculates when the day appears in specific month
 *
 * @package core
 * @category time
 * @param int $startday starting day of the month
 * @param int $weekday The day when week starts (normally taken from user preferences)
 * @param int $month The month whose day is sought
 * @param int $year The year of the month whose day is sought
 * @return int
 */
function find_day_in_month($startday, $weekday, $month, $year)
{
    $calendartype = \core_calendar\type_factory::get_calendar_instance();
    $daysinmonth = days_in_month($month, $year);
    $daysinweek = count($calendartype->get_weekdays());
    if ($weekday == -1) {
        // Don't care about weekday, so return:
        //    abs($startday) if $startday != -1
        //    $daysinmonth otherwise.
        return $startday == -1 ? $daysinmonth : abs($startday);
    }
    // From now on we 're looking for a specific weekday.
    // Give "end of month" its actual value, since we know it.
    if ($startday == -1) {
        $startday = -1 * $daysinmonth;
    }
    // Starting from day $startday, the sign is the direction.
    if ($startday < 1) {
        $startday = abs($startday);
        $lastmonthweekday = dayofweek($daysinmonth, $month, $year);
        // This is the last such weekday of the month.
        $lastinmonth = $daysinmonth + $weekday - $lastmonthweekday;
        if ($lastinmonth > $daysinmonth) {
            $lastinmonth -= $daysinweek;
        }
        // Find the first such weekday <= $startday.
        while ($lastinmonth > $startday) {
            $lastinmonth -= $daysinweek;
        }
        return $lastinmonth;
    } else {
        $indexweekday = dayofweek($startday, $month, $year);
        $diff = $weekday - $indexweekday;
        if ($diff < 0) {
            $diff += $daysinweek;
        }
        // This is the first such weekday of the month equal to or after $startday.
        $firstfromindex = $startday + $diff;
        return $firstfromindex;
    }
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:52,代码来源:moodlelib.php

示例13: fetch_days_in_month

 /**
  * Fetch Days in Month
  *
  * Returns the number of days for the given month/year
  * Takes leap years into consideration
  *
  * @access	public
  * @param	string
  * @param	string
  * @return	int
  */
 function fetch_days_in_month($month, $year)
 {
     ee()->load->library('logger');
     ee()->logger->deprecated('2.6', 'Date helper\'s days_in_month()');
     ee()->load->helper('date');
     return days_in_month($month, $year);
 }
开发者ID:nigelpeters,项目名称:css-recruitment-ee,代码行数:18,代码来源:Localize.php

示例14: add_cells

 public function add_cells($cells, $start_year, $end)
 {
     /* BENCHMARK */
     $this->benchmark->mark('func_add_cells_start');
     for ($y = $start_year; $y < 2100; $y++) {
         for ($m = 1; $m < 13; $m++) {
             // tell the array which month day it is
             $month_day_count = array('1' => 0, '2' => 0, '3' => 0, '4' => 0, '5' => 0, '6' => 0, '7' => 0);
             if ($y >= $start_year) {
                 for ($d = 1; $d <= days_in_month($m, $y); $d++) {
                     // format with leading zeros
                     if ($d < 10 ? $day = '0' . $d : ($day = $d)) {
                     }
                     if ($m < 10 ? $month = '0' . $m : ($month = $m)) {
                     }
                     // count the days in the month
                     $day_num = format_date($y . "-" . $month . "-" . $day, 'N');
                     $month_day_count[$day_num]++;
                     // add new cell to calendar - only if one doesn't already exist
                     if (!isset($cells[$y . $month . $day])) {
                         $cells[$y . $month . $day] = array('e' => array(), 'dn' => $day_num, 'md' => $month_day_count[$day_num] . " " . $day_num, 'x' => array());
                     }
                     // break if we have reached the last day
                     if ($y . $month . $day == $end) {
                         break 3;
                     }
                 }
             }
         }
     }
     return $cells;
     /* BENCHMARK */
     $this->benchmark->mark('func_add_cells_end');
 }
开发者ID:toni-leigh,项目名称:core,代码行数:34,代码来源:events_admin_model.php

示例15: ajax_refresh_subtotal

 function ajax_refresh_subtotal()
 {
     $rid = $this->input->get('hosting_id');
     $checkin = $this->input->get('checkin');
     $checkout = $this->input->get('checkout');
     $guests = $this->input->get('number_of_guests');
     $res = array();
     $checkin_ts = strtotime($checkin);
     $checkout_ts = strtotime($checkout);
     $first_day_weekly = strtotime('-' . date('w', $checkin_ts) . ' day', $checkin_ts);
     $first_day_monthly = mktime(0, 0, 0, date('m', $checkin_ts), 1, date('Y', $checkin_ts));
     $nights = ($checkout_ts - $checkin_ts) / 86400;
     $room = $this->rooms_model->get_room_prices($rid);
     // TODO Translate
     if (!$room) {
         $res['reason_message'] = 'Property not exists';
     }
     $room = $room[0];
     if (!$room->active) {
         $res['reason_message'] = 'Property turend off';
     } else {
         if ($nights < $room->min_nights) {
             $res['reason_message'] = 'Min nights is ' . $room->min_nights;
         } else {
             if ($nights > $room->max_nights) {
                 $res['reason_message'] = 'Max nights is ' . $room->max_nights;
             } else {
                 if ($guests > $room->person_capacity) {
                     $res['reason_message'] = 'Max guests is ' . $room->person_capacity;
                 }
             }
         }
     }
     if (!empty($res['reason_message'])) {
         $res['available'] = FALSE;
         echo json_encode($res);
         return;
     }
     $this->load->model('calendar_model');
     $this->load->helper('date');
     $daily_list = $this->calendar_model->get_daily($rid, $checkin, $checkout);
     if (!empty($daily_list)) {
         foreach ($daily_list as $i) {
             if (!$i->available) {
                 $res['available'] = FALSE;
                 $res['reason_message'] = 'Those dates are not available';
                 // TODO translate
                 $res['daily_list'] = $daily_list;
                 echo json_encode($res);
                 return;
             }
         }
     }
     $d = $m = $w = 0;
     $monthly_price_default = $room->monthly_price_native > 0 ? $room->monthly_price_native : $room->price_native;
     $weekly_price_default = $room->weekly_price_native > 0 ? $room->weekly_price_native : $room->price_native;
     if ($nights >= 28) {
         $monthly_list = $this->calendar_model->get_monthly($rid, $first_day_monthly, $checkout);
         $res['monthly_list'] = $monthly_list;
         // for debug
         $days_in_month = days_in_month(date('m', $checkin_ts), date('Y', $checkin_ts));
         if (!empty($monthly_list[0]) && strtotime($monthly_list[0]->date) < $checkin_ts) {
             $monthly_price = round($monthly_list[$m++]->price / $days_in_month, 2);
         } else {
             $monthly_price = round($room->monthly_price_native / $days_in_month, 2);
         }
         // TODO: exchange
     }
     if ($nights >= 7) {
         $weekly_list = $this->calendar_model->get_weekly($rid, $first_day_weekly, $checkout);
         $res['weekly_list'] = $weekly_list;
         // for debug
         if (!empty($weekly_list[0]) && strtotime($weekly_list[0]->date) < $checkin_ts) {
             $weekly_price = round($weekly_list[$w++]->price / 7, 2);
         } else {
             $weekly_price = round($room->weekly_price_native / 7, 2);
         }
         // TODO: exchange
     }
     $total_price = 0;
     for ($i = $checkin_ts, $d; $i <= $checkout_ts; $i += 86400) {
         // 가격기준 정하기 (월/주/일)
         if (isset($montly_price) && date('m', $i) == 1) {
             unset($monthly_price);
             $days_in_month = days_in_month(time('m', $i), time('Y', $i));
             if (!empty($monthly_list[$m]) && strtotime($monthly_list[$m]) == $i) {
                 $monthly_price = round($monthly_list[$m++]->price / $days_in_month, 2);
             } else {
                 $monthly_price = round($room->monthly_price_native / $days_in_month, 2);
             }
             // TODO: exchange
         } else {
             if (isset($weekly_price) && date('w', $i) == 0) {
                 unset($weekly_price);
                 if (!empty($weekly_list[$w]) && strtotime($weekly_list[$w]->date) == $i) {
                     $weekly_price = round($weekly_list[$w++]->price / 7, 2);
                 } else {
                     $weekly_price = round($room->weekly_price_native / 7, 2);
                 }
                 // TODO: exchange
//.........这里部分代码省略.........
开发者ID:picapollo,项目名称:rdirect,代码行数:101,代码来源:rooms.php


注:本文中的days_in_month函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。