summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/date_helper.php5
-rw-r--r--system/libraries/Calendar.php19
-rw-r--r--user_guide_src/source/changelog.rst6
-rw-r--r--user_guide_src/source/helpers/date_helper.rst3
-rw-r--r--user_guide_src/source/libraries/calendar.rst3
5 files changed, 17 insertions, 19 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 56e5c46aa..73fd8086e 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -278,6 +278,11 @@ if ( ! function_exists('days_in_month'))
$year = date('Y');
}
+ if (defined('CAL_GREGORIAN'))
+ {
+ return cal_days_in_month(CAL_GREGORIAN, $month, $year);
+ }
+
if ($year >= 1970)
{
return (int) date('t', mktime(12, 0, 0, $month, 1, $year));
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 23c389e4b..7bdcdca09 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -456,23 +456,8 @@ class CI_Calendar {
*/
public function get_total_days($month, $year)
{
- $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
-
- if ($month < 1 OR $month > 12)
- {
- return 0;
- }
-
- // Is the year a leap year?
- if ($month == 2)
- {
- if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0))
- {
- return 29;
- }
- }
-
- return $days_in_month[$month - 1];
+ $this->load->helper('date');
+ return days_in_month($month, $year);
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index ccbb950af..a3e79805f 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -65,11 +65,12 @@ Release Date: Not Released
- :doc:`Date Helper <helpers/date_helper>` changes include:
- - :func:`now()` now works with all timezone strings supported by PHP.
- Added an optional third parameter to :func:`timespan()` that constrains the number of time units displayed.
- Added an optional parameter to :func:`timezone_menu()` that allows more attributes to be added to the generated select tag.
- - Deprecated ``standard_date()``, which now just uses the native ``date()`` with `DateTime constants <http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_.
- Added function :func:`date_range()` that generates a list of dates between a specified period.
+ - Deprecated ``standard_date()``, which now just uses the native ``date()`` with `DateTime constants <http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_.
+ - Changed :func:`now()` to work with all timezone strings supported by PHP.
+ - Changed :func:`days_in_month()` to use the native ``cal_days_in_month()`` PHP function, if available.
- :doc:`URL Helper <helpers/url_helper>` changes include:
@@ -301,6 +302,7 @@ Release Date: Not Released
- Added configuration to generate days of other months instead of blank cells.
- Added auto-configuration for *next_prev_url* if it is empty and *show_prev_next* is set to TRUE.
- Added support for templating via an array in addition to the encoded string.
+ - Changed method ``get_total_days()`` to be an alias for :doc:`Date Helper <helpers/date_helper>` :func:`days_in_month()`.
- :doc:`Cart Library <libraries/cart>` changes include:
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index 39a9cb325..d9019a203 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -268,6 +268,9 @@ The following functions are available:
If the second parameter is empty, the current year will be used.
+ .. note:: This function will alias the native ``cal_days_in_month()``, if
+ it is available.
+
.. function:: date_range([$unix_start = ''[, $mixed = ''[, $is_unix = TRUE[, $format = 'Y-m-d']]]])
:param int $unix_start: UNIX timestamp of the range start date
diff --git a/user_guide_src/source/libraries/calendar.rst b/user_guide_src/source/libraries/calendar.rst
index b4f95db1b..20832740b 100644
--- a/user_guide_src/source/libraries/calendar.rst
+++ b/user_guide_src/source/libraries/calendar.rst
@@ -286,6 +286,9 @@ Class Reference
echo $this->calendar->get_total_days(2, 2012);
// 29
+ .. note:: This method is an alias for :doc:`Date Helper
+ <../helpers/date_helper>` function :func:`days_in_month()`.
+
.. method:: default_template()
:returns: An array of template values