Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[VarDumper] Add time zone caster#23591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:3.4frommaidmaid:vardumper-tz
Jul 21, 2017

Conversation

maidmaid
Copy link
Contributor

@maidmaidmaidmaid commentedJul 19, 2017
edited
Loading

QA
Branch?3.4
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#22431 (comment)
LicenseMIT
Doc PR/

@maidmaid
Copy link
ContributorAuthor

Proposal (exlude verbose mode):

screenshot from 2017-07-19 15-31-17

@maidmaidmaidmaidforce-pushed thevardumper-tz branch 2 times, most recently from76fae7d to4d37445CompareJuly 19, 2017 14:05
Copy link
Contributor

@ro0NLro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

cool 👍

@@ -28,7 +28,8 @@
},
"suggest": {
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-symfony_debug": ""
"ext-symfony_debug": "",
"ext-inlt": "To show region in time zone dump"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ext-intl

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Oops, fixed ;)

@@ -32,7 +32,7 @@ public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub,
;

$a = array();
$a[$prefix.'date'] = new ConstStub($d->format('Y-m-d H:i:s.u '.($location ? 'e (P)' : 'P')), $title);
$a[$prefix.'date'] = new ConstStub($d->format('Y-m-d H:i:s.u ').self::formatTimeZone($d->getTimezone()), $title);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

perhaps inline $location above

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed

@maidmaidmaidmaidforce-pushed thevardumper-tz branch 3 times, most recently from132df43 to27bf394CompareJuly 19, 2017 14:25
@nicolas-grekas
Copy link
Member

(but tests are red)

ro0NL reacted with thumbs up emoji

@ro0NL
Copy link
Contributor

hhvm being weird :)Locale::getDisplayRegion() expects exactly 2 parameters, 1 given

@maidmaid
Copy link
ContributorAuthor

I hate you hhvm! I add a 2ndnull arg.

@ro0NL
Copy link
Contributor

Agree :) this is insane.

I believe windows was failing due missing intl =/ lets see :)

@maidmaid
Copy link
ContributorAuthor

On AppVeyor, Intl component takes over andthis throws an exception. How fix this?

@ro0NL
Copy link
Contributor

try/catch it? Ideally it would be implemented foren locale i guess.

if (($location = $timeZone->getLocation()) && method_exists('\Locale', 'getDisplayRegion')) {
try {
$title = \Locale::getDisplayRegion('-'.$location['country_code'], null);
} catch (\Exception $e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i'd catchSymfony\Component\Intl\Exception\MethodNotImplementedException explicitly here. Anything else should trow.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I finally handled this withextension_loaded('intl') but I'm not sure. Is it good for you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sounds good 👍

@@ -111,6 +111,7 @@

'DateTimeInterface' => array('Symfony\Component\VarDumper\Caster\DateCaster', 'castDateTime'),
'DateInterval' => array('Symfony\Component\VarDumper\Caster\DateCaster', 'castInterval'),
'DateTimeZone' => array('Symfony\Component\VarDumper\Caster\DateCaster', 'castTimeZone'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Im assuming next is DatePeriod for completion? That can be easily wired now.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes! But let's first fully agree on time zone 😅

@@ -28,7 +28,8 @@
},
"suggest": {
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-symfony_debug": ""
"ext-symfony_debug": "",
"ext-intl": "To show region in time zone dump"
Copy link
Contributor

@ro0NLro0NLJul 19, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

To show region name in a time zone dump?

Also perhaps move 1 line up.

maidmaid reacted with thumbs up emoji
$title = '';
if (($location = $timeZone->getLocation()) && method_exists('\Locale', 'getDisplayRegion')) {
try {
$title = \Locale::getDisplayRegion('-'.$location['country_code'], null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

null =>\Locale::getDefault() that be safest

seehttps://3v4l.org/eAigW

maidmaid reacted with thumbs up emoji
@maidmaidmaidmaidforce-pushed thevardumper-tz branch 2 times, most recently from0d2ad57 to7f97d70CompareJuly 20, 2017 07:46
@maidmaid
Copy link
ContributorAuthor

Tests are green :)


private static function formatTimeZone(\DateTimeZone $z)
{
return (new \Datetime('now', $z))->format($z->getLocation() ? 'e (P)' : 'P');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this method should be removed, it forces repeated calls to getLocation that inlinfing prevented - I'm sure things will be easier to read when removed. That means all changes on the castDateTime method should be reverted to me.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Updated


public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, $isNested, $filter)
{
$title = ($location = $timeZone->getLocation()) && extension_loaded('intl')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

$location on its own line + $title on a single line would be better imho

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Updated (although this line is a bit long now...)

@maidmaid
Copy link
ContributorAuthor

Time to merge?

{
$location = $timeZone->getLocation();
$formatted = (new \Datetime('now', $timeZone))->format($location ? 'e (P)' : 'P');
$title = $location && extension_loaded('intl') ? \Locale::getDisplayRegion('-'.$location['country_code'], \Locale::getDefault()) : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

just realized, does it make sense to useLocale::getDefault() instead of justen. Not sure this output needs to be localized at all 😕

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

dump output is already locale sensitive, so this makes sense to me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

date format incastDateTime is not.. which made me think this should follow.

No blocker for me or so :)

@nicolas-grekas
Copy link
Member

Thank you@maidmaid.

@nicolas-grekasnicolas-grekas merged commit5c4bfac intosymfony:3.4Jul 21, 2017
nicolas-grekas added a commit that referenced this pull requestJul 21, 2017
This PR was merged into the 3.4 branch.Discussion----------[VarDumper] Add time zone caster| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#22431 (comment)| License       | MIT| Doc PR        | /Commits-------5c4bfac Add time zone caster
@maidmaidmaidmaid deleted the vardumper-tz branchJuly 21, 2017 13:45
nicolas-grekas added a commit that referenced this pull requestAug 29, 2017
This PR was merged into the 3.4 branch.Discussion----------[VarDumper] Add period caster| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#23591 (comment)| License       | MIT| Doc PR        | /Result:![](https://user-images.githubusercontent.com/4578773/29788181-fce3eb32-8c31-11e7-9da4-72c038d5a14e.png)Commits-------4c4c398 Add period caster
symfony-splitter pushed a commit to symfony/var-dumper that referenced this pull requestAug 29, 2017
This PR was merged into the 3.4 branch.Discussion----------[VarDumper] Add period caster| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |symfony/symfony#23591 (comment)| License       | MIT| Doc PR        | /Result:![](https://user-images.githubusercontent.com/4578773/29788181-fce3eb32-8c31-11e7-9da4-72c038d5a14e.png)Commits-------4c4c398 Add period caster
This was referencedOct 18, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@ro0NLro0NLro0NL approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@maidmaid@nicolas-grekas@ro0NL@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp