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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve date & time formats #8282
Conversation
389b123
to
844e3f7
Compare
be5f09d
to
378a726
Compare
@sgiehl Date formats have changed on master (e.g. http://builds-artifacts.piwik.org/ui-tests.master/14276.7/ActionsDataTable_segmented_visitor_log or http://builds-artifacts.piwik.org/ui-tests.master/14276.7/EvolutionGraph_export_image) is it by any chance related to this (or another PR maybe)? (sorry if I'm a little out of topic :) ) In any case, are the new formats good? (i.e. should I update the screenshots?) |
@mnapoli That shouldn't be on master, as this PR is not merged. Those screenshots were build on the branch: See https://travis-ci.org/piwik/piwik/builds/71750226 The changes done here are still for discussion. Maybe some formats should be adjusted, but I tried to use those fitting best. |
Ah thank you, I was tricked by the "PR build" of travis which ends up in the "master" branch in our build-artifacts servers. All good then! |
308c482
to
f099bdd
Compare
*/ | ||
public function getLocalized($template) | ||
{ | ||
$template = $this->replaceLegacyPlaceholders($template); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to do this only if $template
starts with %
? I'm not sure how often getLocalized
is called... If it is not often called it won't be needed I reckon. Thinking more re performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only called when outputting some dates. But I guess we could check for % and only do the legacy stuff then
Just BTW: At some point (for Piwik 3.0 or 4.0) it would be nice to split the Date classes in different classes. Eg Date and DateFormatter or maybe more classes. Using an existing lib would be even better but probably very hard to replace the current one without regressions. |
We might use something like http://carbon.nesbot.com/ |
Understood. So maybe we should create our own library? i know that it's not that easy but would be much better. |
Yeah I thought it will be hard to find one that has all the features we have or to find maybe one that has most features and that we can extend. If we find one it will be hard to replace the lib and to make sure everything still works as our date lib has some "special behaviours" :) I reckon splitting the |
@tsteur I've done the commented changes. Btw. I don't think we should merge that for 2.15.0 |
Merging directly into 3.0 sounds good to me if not needed earlier. Not sure if you have to rebase. Might be possible to just create another PR and select "3.0" there. LGTM |
Will be rebased and merge to 3.0 branch |
This PR aims to improve the date & time formats used by Piwik.
❗ This PR will also change most of the visible english date/time formats
Current behavior
CoreHome_DateFormat
,CoreCome_MonthLong
,CoreHome_ShortWeekFormat
and others. Those keys contain placeholders like%shortMonth%
,%longYear%
,%longDay
and others, beeing replaced while getting a localized date. See Date.phpThose formats have already been localized to some language. Unfortunately sometimes someone made errors in translating those format strings, which resulted in incomplete/incorrect dates in piwik for that language.
CoreHome_ShortWeekFormat
) had kind of fixed format patterns, making no difference depending on the range beeing within a month, year or not.H:i:s
resulting in not localized time formatsBehaviour with this PR
Examples for english range formats:
Oct 7 – 13, 2024
Nov 25 – Dec 1, 2024
Dec 30, 2024 – Jan 5, 2025