Hi,
when save discount in Persian language, the date not store in database.
Yes, that's what I meant when I said
which then discard the dates as they are incorrect for the Hijri calendar
So I did some tests on my end and when I use the Persian language and create a new discount with a start and end date and save it once, the date is properly stored in the database. And the value stored correspond to the correct date. The numbers you see there correspond to the unix timestamp:
www.unixtimestamp.com/
The problem appears on my end when I open again the discount. Then, the calendar date is wrong.
The date 1400-05-03 01:03 becomes ۷۸۱-۰۱-۰-۶۸۶ ۰۱:۰۳
And In think that it's because the date 1400-05-03 01:03 is already converted to the Persian calendar before it is sent to the Joomla calendar system, which then converts it again and thus you get a double conversion. But I'm not sure how to read the date ۷۸۱-۰۱-۰-۶۸۶ ۰۱:۰۳ so I'm not sure if my theory is correct.
If so, it means that we need to handle the date differently when sending it to Joomla calendar's system as we don't want to convert it in the current language calendar.
I've tried replacing the code:
$date = JHTML::_('date', $time, $format, false);
by:
jimport('joomla.utilities.date');
$date = new JDate($time);
$date = $date->format( $format, true, false);
in the file administrator/components/com_hikashop/helpers/helper.php
This basically does the same thing, but avoids that the language file overrides the date conversion and thus the date is not converted anymore to the Hijri calendar before being sent to the calendar system of Joomla.
This seems to fix the problem on my end. Cna you confirm on your end ?
However, since we use the same function everywhere we display the dates, like on the discounts listing, they now appear with the Gregorian calendar, even when the current language is in Persian.
Now, this could be solved by adding a switch in the hikashop_getDate function to use one mode or the other based on whether we're displaying the date, or sending it to the calendar system. But it would require a bit more development work.