Story #5583

DateFormat View Helper doesn't respect locale setting

Added by Susanne Moog over 5 years ago. Updated about 4 years ago.

Status:Closed Start date:2009-11-30
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:ViewHelpers
Target version:-
Has patch:

Description

Hi [this is related to fluid, I don't know if this is the right bugtracker],

just found out that the format date viewhelper does not support local date settings (day or month names etc) because it uses the DateFormat object that does not care for the locale.

A short test case shows this:

dateTime->format('l, d. F Y'): Monday, 30. November 2009
strftime('%A, %d. %B %G'): Monday, 30. November 2009

setlocale(LC_ALL, 'de_DE.utf8');

dateTime->format('l, d. F Y'): Monday, 30. November 2009
strftime('%A, %d. %B %G'): Montag, 30. November 2009

(compare "Monday" and "Montag" in the last part)

Code:

$dateTime = new DateTime();
echo 'dateTime->format(\'l, d. F Y\'):';
echo $dateTime->format('l, d. F Y');
echo 'strftime(\'%A, %d. %B %G\'):';
echo strftime('%A, %d. %B %G');
echo "\n";
echo 'setlocale(LC_ALL, \'de_DE.utf8\')' . "\n\n";
setlocale(LC_ALL, 'de_DE.utf8');
echo 'dateTime->format(\'l, d. F Y\'):';
echo $dateTime->format('l, d. F Y');
echo 'strftime(\'%A, %d. %B %G\'):';
echo strftime('%A, %d. %B %G');

We could probably use strftime for locales other than en_US (or always?). If you think that reasonable I'll try making a patch at the weekend.


Related issues

related to news extension - Task #14085: translate newsItem.datetime in FE Resolved 2011-03-28
duplicates TYPO3.Fluid - Bug #4972: f:format.date does not respect locale. Closed 2009-10-12

History

#1 Updated by Franz Koch about 5 years ago

any news on that? It's a shame that dates don't get localized by the dateTime object of PHP. I solved it for now by using my own viewHelper, but that's no overall solution.

#2 Updated by Sebastian Kurfuerst over 4 years ago

  • Tracker changed from Bug to Story
  • Status changed from New to Needs Feedback

For now, I suggest to use a second ViewHelper -- if you have one, please post it to the VH incubator. We'd love to see one soon :-)

Greets,
Sebastian

#3 Updated by Sebastian Kurfuerst over 4 years ago

  • Project changed from Extbase MVC Framework to TYPO3.Fluid

#4 Updated by Sebastian Kurfuerst over 4 years ago

  • Category set to ViewHelpers
  • Branch set to v4 + v5

#5 Updated by Sebastian Kurfuerst about 4 years ago

  • Status changed from Needs Feedback to Closed

duplicate

Also available in: Atom PDF