yii2-usuario icon indicating copy to clipboard operation
yii2-usuario copied to clipboard

User admin list broken date

Open mrbig00 opened this issue 6 years ago • 12 comments

What steps will reproduce the problem?

At the users list the dates are not displayed properly

What is the expected result?

24 oct. 2017, 19:30:40

What do you get instead?

{0, data, MMMM dd, AAAA HH: mm}

Also for some reason it's taking 2-3 secs to load the page. I've made a quick fix and I've changed the date columns to use the Yii's date formatter:

 [
        'attribute' => 'last_login_at',
        'format'    => 'raw',
        'value'     => function ($model) {
            return \Yii::$app->formatter->asDatetime($model->last_login_at);
        },
],

I think that it's more better to use the Yii formatters because:

  • they work
  • don't have to put HTML code in classes
  • page loads faster
  • much less spaghetti

mrbig00 avatar Jul 12 '18 18:07 mrbig00

What language are you using for your app? are you sure you get data instead of date? What's the exact output string you get? Because I see it correctly in Italian:

screenshot-localhost-2018-07-13-09-03-39

About the output string I would agree in using Yii's formatting tools instead of writing custom formatting, I don't know why @tonydspaniard started using that notation... Anyway you could do even less code: there's no need to explicitly call formatter, you could leave the column as

'last_login_at:datetime',

But I'd rather open a new issue for this

maxxer avatar Jul 13 '18 07:07 maxxer

oh, I forgot about the datetime format :grin:

I'm using english/hungarian/romanian languages but I didn't overwrite the view until today to fix this issue.

mrbig00 avatar Jul 13 '18 10:07 mrbig00

You mean even with english language you didn't see the date but the string above?

maxxer avatar Jul 13 '18 10:07 maxxer

Yes

mrbig00 avatar Jul 16 '18 13:07 mrbig00

Unfortunately I cannot reproduce the issue. Can you give a try with 1.5-beta or latest master to see if it has been fixed? My guess (and hope) is this. Otherwise you must do some debugging yourself... Let me know

maxxer avatar Jul 16 '18 14:07 maxxer

What do you think about refactoring this view to use the standard column formats for date, like: 'last_login_at:datetime'. In the weekend I can make a PR if it's okay.

I think that it will improve the readability and solve this issue.

I have the same problem with 1.5-beta + also I have the same strange issue that the page load takes ~2 seconds longer if I use the original version instead of the last_login_at:datetime version

mrbig00 avatar Aug 02 '18 08:08 mrbig00

I'm ok with using standard date and time formatting. If @tonydspaniard have nothing against it you can go (but I personally will not merge before aug 21st).

The long loading time is very curious, tough. Doesn't the yii2-debug toolbard help you in finding the culprit?

maxxer avatar Aug 02 '18 08:08 maxxer

I haven't had time yet to investigate this issue, so I just replaced the column with datetime. After August 21 I will make a PR.

mrbig00 avatar Aug 02 '18 08:08 mrbig00

@maxxer @mrbig00 is this issue still valid?

tonydspaniard avatar Jun 29 '19 06:06 tonydspaniard

Yes. For example here, why handling intl presence? Isn't Yii doing it already? I'd replace these with just

created_at:datetime

so date display is handled by Yii. Also, if someone has custom date formatting it's taken into consideration, instead of doing a custom visualization in usuario.

If you have nothing against dropping intl checks I'd make a patch with those changes

maxxer avatar Jul 02 '19 10:07 maxxer

Thanks for your answer @maxxer

tonydspaniard avatar Jul 17 '19 11:07 tonydspaniard

created_at:datetime

That would be the perfect solution!

mrbig00 avatar Jul 24 '19 07:07 mrbig00