getk2 / k2

K2 - the powerful content extension for Joomla
https://getk2.org
GNU General Public License v3.0
136 stars 95 forks source link

Wrong Date Convert on Adding Item in Farsi (Persian) Language #247

Closed majidmahdavi closed 9 years ago

majidmahdavi commented 9 years ago

on Adding new Item (When no date chosen yet), date printed in HTML source in Jalali format , so the datetime picker try to convert it again to Jalali and result will be so wrong date.

the only thing that working right, is on submitting form ( when i choose correct date by picker) and save the form, before saving, date converted to Georgian, but again when form loaded, it has printed Jalali date in HTML and again like new state

summary: everything is fine when submitting form but when form loaded ( adding new item, or editing item directly from database) it shows jalali date in HTML which is wrong approach

solve proposal: Date have to be printed in Georgian in Date input HTML and have to be converted to jalali in run time by java-script (which just working fine only submit event, not load)

my question: how to stop k2 to not convert date in jalali in HTML Source?

majidmahdavi commented 9 years ago

After investigating k2 source codes, i figured it up how to fix that!

i just commented this lines: started at line number 137 from view.html.php at administrator\components\com_k2\views\item

    //$created = JHTML::_('date', $item->created, $dateFormat);
    //$publishUp = JHTML::_('date', $item->publish_up, $dateFormat);
    if ((int)$item->publish_down)
    {
        //$publishDown = $item->publish_down;JHTML::_('date', $item->publish_down, $dateFormat);
    }
    else
    {
        $publishDown = '';
    }
majidmahdavi commented 9 years ago

it seems JHTML:: convert date to admin user logged-in language and thats cause the problem, i like to hear the main reason of that by author, please bright me up

majidmahdavi commented 9 years ago

i compared k2 item to Joomla Content Article source code, and understood that content article wont convert date, just simply using JFactory::getDate()->toSql();

but in k2 after that using JHTML::