Story #5583

DateFormat View Helper doesn't respect locale setting

Added by Susanne Moog about 12 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
ViewHelpers
Target version:
-
Start date:
2009-11-30
Due date:
% Done:

0%

Estimated time:
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

Is duplicate of TYPO3.Fluid - Bug #4972: f:format.date does not respect locale.Closed2009-10-12

Actions
#1

Updated by Franz Koch over 11 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 almost 11 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 almost 11 years ago

  • Project changed from 534 to TYPO3.Fluid
#4

Updated by Sebastian Kurfuerst almost 11 years ago

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

Updated by Sebastian Kurfuerst over 10 years ago

  • Status changed from Needs Feedback to Closed

duplicate

Also available in: Atom PDF