QDateTimeTextBox format and localization

Login or register to post comments
7 replies [Last post]
Offline
Joined: 08/12/2009

Hi,

I'm using a QDateTimeTextBox with a QCalendar and I'd like to set the format of textbox date - how/where can I do this? Also, the dhtml calendar is in english and I'd like it to be localized.

My application is already localized and DateTime is setup like this:

<?php
QDateTime
::$DefaultFormat = 'YYYY-MM-DD';
QApplication::$CountryCode = 'pt';
QApplication::$LanguageCode = 'pt';
?>

in my prepend.inc.php file but those two controls don't respect this settings.

Thanks.

Offline
Joined: 08/12/2009

anyone? :)

alex94040's picture
Offline
Joined: 11/06/2008

Look through the code of these controls, you'll see the piece that is responsible for outputting the date. It might very well not be localized.

Offline
Joined: 08/12/2009

tks Alex, will do

vakopian's picture
Offline
Joined: 04/08/2008

cmpscabral,

Both QDateTimeTextBox and QCalendar have a DateTimeFormat (QCalendar also has a synonymous DateFormat) property, that will allow you to control the format. However I highly doubt there is any localization for either of these controls. In fact looking at the code, even the error messages are not properly localized for this class.

-Vartan

Offline
Joined: 08/06/2010

I wanted date in dd.mm.yyyy format so i had to remove line from QDateTimeTextBox.class
in public static function ParseForDateTimeValue($strText) line 48
$strText = str_replace('.', '', $strText);

What is the reason for this replacement?

http://www.php.net/manual/en/datetime.formats.date.php

vakopian's picture
Offline
Joined: 04/08/2008

Mile,

I agree, it seems completely arbitrary to replace the dot and "@".
In fact the whole function is pretty bad. If any of the cleanup in that function is really necessary, why not make QDateTime do it? For example why shouldn't QDateTime itself handle "10pm"? And to handle different formats, we could use date_create_from_format() (or date_parse_from_format()) before we pass it to QDateTime.

-Vartan

alex94040's picture
Offline
Joined: 11/06/2008

All fair points. Does one of you want to take a stab at a patch?