Update to CodeIgniter 3.19
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2018, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @copyright Copyright (c) 2014 - 2018, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
@@ -496,6 +496,7 @@ if ( ! function_exists('nice_date'))
|
||||
* Turns many "reasonably-date-like" strings into something
|
||||
* that is actually useful. This only works for dates after unix epoch.
|
||||
*
|
||||
* @deprecated 3.1.3 Use DateTime::createFromFormat($input_format, $input)->format($output_format);
|
||||
* @param string The terribly formatted date-like string
|
||||
* @param string Date format to return (same as php date function)
|
||||
* @return string
|
||||
@@ -529,9 +530,9 @@ if ( ! function_exists('nice_date'))
|
||||
}
|
||||
|
||||
// Date Like: YYYYMMDD
|
||||
if (preg_match('/^(\d{2})\d{2}(\d{4})$/i', $bad_date, $matches))
|
||||
if (preg_match('/^\d{8}$/i', $bad_date, $matches))
|
||||
{
|
||||
return date($format, strtotime($matches[1].'/01/'.$matches[2]));
|
||||
return DateTime::createFromFormat('Ymd', $bad_date)->format($format);
|
||||
}
|
||||
|
||||
// Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between)
|
||||
@@ -707,87 +708,32 @@ if ( ! function_exists('date_range'))
|
||||
|
||||
$range = array();
|
||||
|
||||
/* NOTE: Even though the DateTime object has many useful features, it appears that
|
||||
* it doesn't always handle properly timezones, when timestamps are passed
|
||||
* directly to its constructor. Neither of the following gave proper results:
|
||||
*
|
||||
* new DateTime('<timestamp>')
|
||||
* new DateTime('<timestamp>', '<timezone>')
|
||||
*
|
||||
* --- available in PHP 5.3:
|
||||
*
|
||||
* DateTime::createFromFormat('<format>', '<timestamp>')
|
||||
* DateTime::createFromFormat('<format>', '<timestamp>', '<timezone')
|
||||
*
|
||||
* ... so we'll have to set the timestamp after the object is instantiated.
|
||||
* Furthermore, in PHP 5.3 we can use DateTime::setTimestamp() to do that and
|
||||
* given that we have UNIX timestamps - we should use it.
|
||||
*/
|
||||
$from = new DateTime();
|
||||
$from->setTimestamp($unix_start);
|
||||
|
||||
if (is_php('5.3'))
|
||||
{
|
||||
$from->setTimestamp($unix_start);
|
||||
if ($is_unix)
|
||||
{
|
||||
$arg = new DateTime();
|
||||
$arg->setTimestamp($mixed);
|
||||
}
|
||||
else
|
||||
{
|
||||
$arg = (int) $mixed;
|
||||
}
|
||||
|
||||
$period = new DatePeriod($from, new DateInterval('P1D'), $arg);
|
||||
foreach ($period as $date)
|
||||
{
|
||||
$range[] = $date->format($format);
|
||||
}
|
||||
|
||||
/* If a period end date was passed to the DatePeriod constructor, it might not
|
||||
* be in our results. Not sure if this is a bug or it's just possible because
|
||||
* the end date might actually be less than 24 hours away from the previously
|
||||
* generated DateTime object, but either way - we have to append it manually.
|
||||
*/
|
||||
if ( ! is_int($arg) && $range[count($range) - 1] !== $arg->format($format))
|
||||
{
|
||||
$range[] = $arg->format($format);
|
||||
}
|
||||
|
||||
return $range;
|
||||
}
|
||||
|
||||
$from->setDate(date('Y', $unix_start), date('n', $unix_start), date('j', $unix_start));
|
||||
$from->setTime(date('G', $unix_start), date('i', $unix_start), date('s', $unix_start));
|
||||
if ($is_unix)
|
||||
{
|
||||
$arg = new DateTime();
|
||||
$arg->setDate(date('Y', $mixed), date('n', $mixed), date('j', $mixed));
|
||||
$arg->setTime(date('G', $mixed), date('i', $mixed), date('s', $mixed));
|
||||
$arg->setTimestamp($mixed);
|
||||
}
|
||||
else
|
||||
{
|
||||
$arg = (int) $mixed;
|
||||
}
|
||||
$range[] = $from->format($format);
|
||||
|
||||
if (is_int($arg)) // Day intervals
|
||||
$period = new DatePeriod($from, new DateInterval('P1D'), $arg);
|
||||
foreach ($period as $date)
|
||||
{
|
||||
do
|
||||
{
|
||||
$from->modify('+1 day');
|
||||
$range[] = $from->format($format);
|
||||
}
|
||||
while (--$arg > 0);
|
||||
$range[] = $date->format($format);
|
||||
}
|
||||
else // end date UNIX timestamp
|
||||
{
|
||||
for ($from->modify('+1 day'), $end_check = $arg->format('Ymd'); $from->format('Ymd') < $end_check; $from->modify('+1 day'))
|
||||
{
|
||||
$range[] = $from->format($format);
|
||||
}
|
||||
|
||||
// Our loop only appended dates prior to our end date
|
||||
/* If a period end date was passed to the DatePeriod constructor, it might not
|
||||
* be in our results. Not sure if this is a bug or it's just possible because
|
||||
* the end date might actually be less than 24 hours away from the previously
|
||||
* generated DateTime object, but either way - we have to append it manually.
|
||||
*/
|
||||
if ( ! is_int($arg) && $range[count($range) - 1] !== $arg->format($format))
|
||||
{
|
||||
$range[] = $arg->format($format);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user