Req #76123 [Opn->Wfx]: Implement Month Genitive and Nominative Names in date format functions
| From: | requinix@php.net | Date: | Wed, 21 Mar 2018 08:18:35 +0000 |
| Subject: | Req #76123 [Opn->Wfx]: Implement Month Genitive and Nominative Names in date format functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214425@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76123&edit=1
ID: 76123
Updated by: requinix@php.net
Reported by: murznn at gmail dot com
Summary: Implement Month Genitive and Nominative Names in
date format functions
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Date/time related
PHP Version: Next Major Version
Block user comment: N
Private report: N
New Comment:
strftime() is not a function that PHP created. It's actually defined in C,
https://www.google.com/search?q=c+strftime
and PHP's strftime() is just a thin "wrapper" around it. So we can't really
change that.
PHP does have date() formatting, but what you're asking for is too complex for us to manage.
The good news is that what you need exists as part of the intl extension. Example: https://3v4l.org/tKUD0
Links:
http://php.net/manual/en/book.intl.php
http://userguide.icu-project.org/formatparse/datetime
Previous Comments:
------------------------------------------------------------------------
[2018-03-21 07:51:19] murznn at gmail dot com
Description:
------------
Some languages have 2 cases of month names - genitive and nominative. Eg in Russian - January have 2
cases - 'ЯнваÑÑ' and 'ÑнваÑÑ', depended on
month place in string.
'1 January' in Russian must be translated as '1 ÑнваÑÑ'
'January, 1' in Russian must be translated as 'ЯнваÑÑ, 1'
But PHP date function have only one case for month name - 'F', that translates to
nominative case, and there are no way to translate in genitive case.
There are many workarounds for this problem via custom scripts, also this already implemented in
some systems, eq in Russian PHP CMS Bitrix: https://dev.1c-bitrix.ru/api_help/main/functions/date/formatdate.php
added 'f' symbol that return month in genitive case.
On some other languages, eg C# - this feature is implemented: https://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.monthgenitivenames.aspx
Because function date() not use locale, my suggestion is to add new symbol to PHP strtotime() and
DateTime::format functions, that will return month name in genitive case with no capital letter. For
example, this can be '%L' symbol, that return localized month name in genitive case.
Or maybe community can provide some better solutions for this problem in PHP core.
P.S. Description of problem in Russian language: ÐÑавилÑное
Ñклонение меÑÑÑа в даÑаÑ
ÑеÑез PHP ÑÑнкÑии strtotime() и DateTime::format в
имениÑелÑном и ÑодиÑелÑном
падежаÑ
на ÑÑÑÑком ÑзÑке.
Test script:
---------------
<?php
setlocale(LC_TIME, 'ru_RU.UTF-8');
echo strftime('%B %L', strtotime('2000-01-01'));
?>
Expected result:
----------------
ЯнваÑÑ ÑнваÑÑ
Actual result:
--------------
ЯнваÑÑ %L
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76123&edit=1