Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

advanced search


Guest

Recommended Posts

I think that there is a little bug in the advanced search procedure:

 

when i search product in a range of date, if the format string that depending of language, for the day is different that 'dd' it say me "invalid date from" and "invalid date to" this obviously is for deutsh language where format string is "tt.mm.jjjj" or italian "gg/mm/aaaa" or french "jj/mm/aaaa" ecc. but not where format string is "dd/mm/yyyy".

 

Have anyone a solution for this problem?

 

Excuse my english

Thanks

Link to comment
Share on other sites

There is a very simple solution indeed. Where did you get the idea to translate the format string??? That doesn't work, so stop doing it.

 

I believe your actual problem is that dd/mm/yyyy didn't work for you and then you started experimenting. But depending on the function to which you are giving the format string, what you probably want is d/m/Y. This will format today's date as 23/10/2003. It would also explain why the computer wouldn't know what to do with 2323/10/10/03030303, which is what you were feeding it. Look here: www.php.net/date.

Link to comment
Share on other sites

Thank you, WillemB for your reply.

 

The question that I have posted is this:

 

First look the file 'catalog/includes/languages/english.php' or german.php or the language you want.

Row n.70 contain this instruction:

italian.php

// text for date of birth example
define('DOB_FORMAT_STRING', 'gg/mm/aaaa');

 

english.php

// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');

 

german.php

// text for date of birth example
define('DOB_FORMAT_STRING', 'tt.mm.jjjj');

 

french.php

// text for date of birth example
define('DOB_FORMAT_STRING', 'jj/mm/aaaa');

 

than you can see that DOB_FORMAT_STRING is the example text for date of birth tipical for any language.

 

But DOB_FORMAT_STRING is used in file 'catalog/advanced_search.php'

 

about line 40

it is used in order to say the customer in which formed it must insert the date in the field.

 

about line 47

    if (!IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) {

 

about line 55

    if (!IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>')) {

 

it is used like parameter passed to the function 'IsValidDate' you can see this function in file 'catalog/includes/general.js'.

 

function IsValidDate(DateToCheck, FormatString) {
...

 

Now the function does not distinguish the format of the date in relation to the used language but DOB_FORMAT_STRING is important in order to communicate a date format given to the customer

 

This is the first check for the date format.

 

In file advanced_search_result.php about line 56 you can see:

 

      if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) {

 

about line 65

      if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) {

 

another function in 'catalog/includes/functions/general.php' check the date format and there I have found the solution:

 

about line 789 search that code:

        if ($format_string_array[$i] == 'dd') $day = $date_to_check_array[$i];
       if ( ($format_string_array[$i] == 'yyyy') || ($format_string_array[$i] == 'aaaa') ) $year = $date_to_check_array[$i];

 

replace with:

        if ($format_string_array[$i] == 'dd' || $format_string_array[$i] == 'gg' || $format_string_array[$i] == 'jj' || $format_string_array[$i] == 'tt') $day = $date_to_check_array[$i];
       if ( ($format_string_array[$i] == 'yyyy') || ($format_string_array[$i] == 'aaaa') || ($format_string_array[$i] == 'jjjj') ) $year = $date_to_check_array[$i];

 

and all works perfectly.

 

But it remains the fact that, if in a particular language the format of the date is various from those cited, the bug returns.

Link to comment
Share on other sites

Hmmm, this is very strange. I simply can't imagine that an English-language system would accept the wrong arguments, because the translated dd/mm/yyyy uses letters that have an entirely different meaning! I don't think PHP is translated in other languages (the code itself).

 

Therefore the problem you are encountering is still the same: it won't accept different languages and therefore you have had to manually change it. The example is therefore just an example, used because Germans may not understand what yyyy means. It definitely does not mean that the argument for the code should also be jjjj in my opinion.

 

Also I don't understand why you won't simply change it, as soon as you use dd/mm/yyyy your code will work right away (for all languages).

 

Finally, my apologies, apparently this function wants the arguments in dd/mm/yyyy, instead of the more standard d/m/Y.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...