From 7312501b75da4d73dd53dd778eb3fa3538e239a0 Mon Sep 17 00:00:00 2001 From: Faxriddin Date: Thu, 9 Oct 2014 15:47:01 +0500 Subject: [PATCH 1/3] correcting word --- docs/guide-uz/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide-uz/README.md b/docs/guide-uz/README.md index e59380ae9a..16315917df 100644 --- a/docs/guide-uz/README.md +++ b/docs/guide-uz/README.md @@ -1,7 +1,7 @@ Yii 2.0 bo'yicha to'liq qo'llanma -============================= +================================= -Ushbu qo'llanma [Yii qo'llanmalarining holati bilan](http://www.yiiframework.com/doc/terms/) bilan mos holda yo'lga qo'yildi. +Ushbu qo'llanma [Yii qo'llanmalarining holati](http://www.yiiframework.com/doc/terms/) bilan mos holda yo'lga qo'yildi. All Rights Reserved. From c489f8228d00a04a8f6868b863fa9305b577f57a Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 9 Oct 2014 14:53:59 +0400 Subject: [PATCH 2/3] Removed unnecessary token generation. We already have it. --- framework/web/Request.php | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/web/Request.php b/framework/web/Request.php index 391c086d17..99512242be 100644 --- a/framework/web/Request.php +++ b/framework/web/Request.php @@ -1287,7 +1287,6 @@ class Request extends \yii\base\Request $config['value'] = $token; Yii::$app->getResponse()->getCookies()->add(new Cookie($config)); } else { - $token = Yii::$app->getSecurity()->generateRandomString(); Yii::$app->getSession()->set($this->csrfParam, $token); } return $token; From 1b052f3e9476483f63544125169a281c2fd66ca8 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 9 Oct 2014 13:16:34 +0200 Subject: [PATCH 3/3] updated formatter docs and allow using DateTimeImmutable see http://derickrethans.nl/immutable-datetime.html by @derickr --- framework/i18n/Formatter.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/framework/i18n/Formatter.php b/framework/i18n/Formatter.php index 6e3773fe0a..86b6cdb119 100644 --- a/framework/i18n/Formatter.php +++ b/framework/i18n/Formatter.php @@ -7,7 +7,9 @@ namespace yii\i18n; +use DateInterval; use DateTime; +use DateTimeInterface; use DateTimeZone; use IntlDateFormatter; use NumberFormatter; @@ -566,7 +568,7 @@ class Formatter extends Component */ protected function normalizeDatetimeValue($value) { - if ($value === null || $value instanceof DateTime) { + if ($value === null || $value instanceof DateTime || $value instanceof DateTimeInterface) { // skip any processing return $value; } @@ -595,13 +597,13 @@ class Formatter extends Component /** * Formats a date, time or datetime in a float number as UNIX timestamp (seconds since 01-01-1970). - * @param integer|string|DateTime|\DateInterval $value the value to be formatted. The following + * @param integer|string|DateTime $value the value to be formatted. The following * types of value are supported: * * - an integer representing a UNIX timestamp - * - a string that can be parsed into a UNIX timestamp via `strtotime()` or that can be passed to a DateInterval constructor. - * - a PHP DateTime object - * - a PHP DateInterval object (a positive time interval will refer to the past, a negative one to the future) + * - a string that can be [parsed to create a DateTime object](http://php.net/manual/en/datetime.formats.php). + * The timestamp is assumed to be in UTC unless a timezone is explicitly given. + * - a PHP [DateTime](http://php.net/manual/en/class.datetime.php) object * * @return string the formatted result. */ @@ -617,15 +619,23 @@ class Formatter extends Component /** * Formats the value as the time interval between a date and now in human readable form. * - * @param integer|string|DateTime|\DateInterval $value the value to be formatted. The following + * This method can be used in three different ways: + * + * 1. Using a timestamp that is relative to `now`. + * 2. Using a timestamp that is relative to the `$referenceTime`. + * 3. Using a `DateInterval` object. + * + * @param integer|string|DateTime|DateInterval $value the value to be formatted. The following * types of value are supported: * * - an integer representing a UNIX timestamp - * - a string that can be parsed into a UNIX timestamp via `strtotime()` or that can be passed to a DateInterval constructor. - * - a PHP DateTime object + * - a string that can be [parsed to create a DateTime object](http://php.net/manual/en/datetime.formats.php). + * The timestamp is assumed to be in UTC unless a timezone is explicitly given. + * - a PHP [DateTime](http://php.net/manual/en/class.datetime.php) object * - a PHP DateInterval object (a positive time interval will refer to the past, a negative one to the future) * - * @param integer|string|DateTime|\DateInterval $referenceTime if specified the value is used instead of `now`. + * @param integer|string|DateTime $referenceTime if specified the value is used as a reference time instead of `now` + * when `$value` is not a `DateInterval` object. * @return string the formatted result. * @throws InvalidParamException if the input value can not be evaluated as a date value. */ @@ -635,7 +645,7 @@ class Formatter extends Component return $this->nullDisplay; } - if ($value instanceof \DateInterval) { + if ($value instanceof DateInterval) { $interval = $value; } else { $timestamp = $this->normalizeDatetimeValue($value); @@ -644,7 +654,7 @@ class Formatter extends Component // $value is not a valid date/time value, so we try // to create a DateInterval with it try { - $interval = new \DateInterval($value); + $interval = new DateInterval($value); } catch (\Exception $e) { // invalid date/time and invalid interval return $this->nullDisplay;