Comments (1)
That seems like a useful change, thanks.
A quick check seems to indicate that in some cases with ccc
and LLL
the result is more consistent with strftime
(see below some locales I had in mind for a quick test). For example for finnish and russian. In most cases it doesn't change anything from MMM/EEE.
So I'd say go for it :)
What would be useful would be to have a test that generates all local date strings using \strftime
and this replacement library and find out which locales have different returns.
<?php
$locales = ['pl_PL', 'fr_FR', 'de_DE', 'nl_NL', 'nl_BE', 'de_CH', 'fr_CH', 'fr_BE', 'zh_CN', 'ru_RU', 'fi_FI', 'sv_SE', 'no_NO', 'ro_RO', 'cs_CZ', 'es_ES', 'pt_PT', 'pt_BR'];
foreach ($locales as $locale) {
echo "$locale\n";
$locale .= '.UTF-8';
setlocale(LC_ALL, $locale);
$i = function($f) use ($locale) {
var_dump((new \IntlDateFormatter($locale, \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, null, null, $f))->format(new DateTime('1 month ago')));
};
var_dump(@strftime('%a %A %b %B', strtotime('1 month ago')));
$i("EEE EEEE MMM MMMM");
$i("ccc cccc LLL LLLL");
setlocale(LC_ALL, 'C'); // Restore locale to detect locales that are not installed
}
pl_PL
string(23) "pią piątek lip lipiec"
string(21) "pt. piątek lip lipca"
string(22) "pt. piątek lip lipiec"
fr_FR
string(27) "ven. vendredi juil. juillet"
string(27) "ven. vendredi juil. juillet"
string(27) "ven. vendredi juil. juillet"
de_DE
string(19) "Fr Freitag Jul Juli"
string(21) "Fr. Freitag Juli Juli"
string(19) "Fr Freitag Jul Juli"
nl_NL
string(19) "vr vrijdag jul juli"
string(20) "vr vrijdag jul. juli"
string(19) "vr vrijdag jul juli"
nl_BE
string(19) "vr vrijdag jul juli"
string(20) "vr vrijdag jul. juli"
string(19) "vr vrijdag jul juli"
de_CH
string(20) "Fre Freitag Jul Juli"
string(21) "Fr. Freitag Juli Juli"
string(19) "Fr Freitag Jul Juli"
fr_CH
string(24) "ven vendredi jui juillet"
string(27) "ven. vendredi juil. juillet"
string(27) "ven. vendredi juil. juillet"
fr_BE
string(24) "ven vendredi jui juillet"
string(27) "ven. vendredi juil. juillet"
string(27) "ven. vendredi juil. juillet"
zh_CN
string(25) "五 星期五 7月 七月"
string(28) "周五 星期五 7月 七月"
string(28) "周五 星期五 7月 七月"
ru_RU
string(35) "Пт Пятница июл Июль"
string(37) "пт пятница июля июля"
string(37) "Пт Пятница Июль Июль"
fi_FI
string(29) "pe perjantai heinä heinäkuu"
string(38) "pe perjantaina heinäkuuta heinäkuuta"
string(29) "pe perjantai heinä heinäkuu"
sv_SE
string(19) "fre fredag jul juli"
string(19) "fre fredag jul juli"
string(19) "fre fredag jul juli"
no_NO
string(19) "Fri Friday Jul July"
string(21) "fre. fredag juli juli"
string(19) "fr. fredag jul juli"
ro_RO
string(19) "Vi vineri iul iulie"
string(20) "Vi vineri iul. iulie"
string(20) "Vi vineri iul. iulie"
cs_CZ
string(25) "Pá Pátek čec červenec"
string(25) "pá pátek čvc července"
string(25) "pá pátek čvc červenec"
es_ES
string(21) "vie viernes jul julio"
string(21) "vie viernes jul julio"
string(21) "vie viernes jul julio"
pt_PT
string(19) "sex sexta jul julho"
string(25) "sex sexta-feira jul julho"
string(25) "sex sexta-feira jul julho"
pt_BR
string(19) "sex sexta jul julho"
string(25) "sex sexta-feira jul julho"
string(25) "sex sexta-feira jul julho"
from strftime.
Related Issues (11)
- PSR-12 compability? HOT 2
- doesn't work with LC_TIME=nb_NO.UTF8 ? HOT 13
- Replace "is_int" check with "is_numeric"? HOT 2
- PHP fatal error "Call to undefined method IntlCalendar::setGregorianChange()" with non-Gregorian locales
- Fatal error when using the default PHP locale HOT 1
- Add phpunit tests HOT 2
- Timezone issue HOT 3
- Minimum PHP version in composer.json is incorrect HOT 2
- 24-hour format of an hour (0 to 23) HOT 8
- Behaves differently from stock `strftime` for the Italian default year format HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from strftime.