We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33992 ☆ A M B ☆
    • 455 Posts
    Hi,
    you know that the output of PHP date functions has been created for Georgian calender and i think output displays only in English language while some countries has special calender for themselves and some countries (languages) does not use English name for months and day weeks
    for example Persian users does not use Georgian calender and use special calender named Jalali or maybe Japanese or Russian users want to display months in their language and etc.

    unfortunately while a script use date() function directly for display date, i (a Persian user) can not use my calender and i must use the default calender and language.

    I created a Georgian to Jalali converter script for Persian users but it didin’t solve main problem because it can use only for Persian user’s script who use converter in their script and for some special snippets which support PHx.

    summary i think it is better to solve problem by MODx dirctly.
    this topic contains my idea for a custom API special for output of date in MODx.

    for do this:
    1.custom scripts and converters should create and put in MODx files. scripts must define functions for date functions (date & strftime) with same arguments.

    2.we need 2 new fields in configuration MODx manager part. one for choosing calender and another for setting GMT. hypothesis these values put in $modx->config[’calender’] & $modx->config[’gmt’] variables.

    3.adding a new method in modx class like below:
    <?php
    class modx {
    .
    .
    	function date ( $format_string , $timestamp ) {
    		$timestamp = $timestamp + $this->config['gmt'] ;
    		
    		if($this->config['calender'] !== 'georgian'){
    			include('...../calender/'.$this->config['calender'].'.php');
    			return custom_date ( $format_string , $timestamp );
    		}
    		else
    			return date ( $format_string , $timestamp );
    	}	
    .
    }
    ?>

    by these codes, i (a Persian user) must define custom_date() function which arguments are same as date() function and put it in a php file named jalali.php.
    i think using date() function with adding GMT value to it is better than using strftime() for local time, because there are many sites that their servers aren’t in their countries so strftime is not good.
    summary do same or some changes in above method make custom_strftime().

    4.in last step, developers should use $modx->date() instead date() in their scripts.


    these are easy in action and make MODx date outputs more customizable and flexible for different countries and languegs!

    that was my idea, what is yours about it? wink


    many thanks
    AHHP
      God loves me. 【ツ】


      MODX.ir (Persian Support)

      Boplo.ir/modx/ (Persian)