<commit_before><?php
/**
 * @author - <NAME> <<EMAIL>>
 * @license - MIT
 * 
 * This is the Behavior class for operations with date.
 * You should define behavior in ActiveRecord class.
 * 
 * public function behaviors() {
 *  return [
 *   'RuDate' => ['class' => RuDate::className()]
 *  ];
 * }
 */
namespace sergmoro1\blog\components;

use Yii;
use yii\base\Behavior;

class RuDate extends Behavior
{
	private static $default = ['ru-RU' => 'd M Y', 'en-US' => 'Y M d'];
    // Russian names of months
    private static $month = ['01'=>'Январь', '02'=>'Февраль', '03'=>'Март', '04'=>'Апрель', '05'=>'Май', '06'=>'Июнь', 
        '07'=>'Июль', '08'=>'Август', '09'=>'Сенябрь', '10'=>'Октябрь', '11'=>'Ноябрь', '12'=>'Декабрь'];

    public function getFullDate($attribute, $format = null)
    {
        $d = $this->owner->$attribute;
        if(!$format)
           $format = self::$default[Yii::$app->language];
        if(Yii::$app->language == 'ru-RU') {
			$format = str_replace('M', mb_substr(self::$month[date('m', $d)], 0, 3), $format);
			$format = str_replace('F', self::$month[date('m', $d)], $format);
			return date($format, $d);
        } else
            return date($format, $d);
    }
}<commit_msg>calculate month number once<commit_after><?php
/**
 * @author - <NAME> <<EMAIL>>
 * @license - MIT
 * 
 * This is the Behavior class for operations with date.
 * You should define behavior in ActiveRecord class.
 * 
 * public function behaviors() {
 *  return [
 *   'RuDate' => ['class' => RuDate::className()]
 *  ];
 * }
 */
namespace sergmoro1\rudate;

use yii\base\Behavior;

class RuDate extends Behavior
{
    private static $default = ['ru-RU' => 'd M Y', 'en-US' => 'Y M d'];
    // Russian names of months
    private static $month = ['01'=>'Январь', '02'=>'Февраль', '03'=>'Март', '04'=>'Апрель', '05'=>'Май', '06'=>'Июнь', 
        '07'=>'Июль', '08'=>'Август', '09'=>'Сенябрь', '10'=>'Октябрь', '11'=>'Ноябрь', '12'=>'Декабрь'];

    public function getFullDate($attribute, $format = null)
    {
        $d = $this->owner->$attribute;
        if(!$format)
            $format = self::$default[\Yii::$app->language];
        if(\Yii::$app->language == 'ru-RU') {
			$m = self::$month[date('m', $d)];
            $format = str_replace('M', mb_substr($m, 0, 3, 'UTF-8'), $format);
            $format = str_replace('F', $m, $format);
        }
        return date($format, $d);
    }
}
{'fraction_non_alphanumeric': 0.22802653399668324, 'fraction_numerical': 0.022802653399668325, 'mean_word_length': 3.285968028419183, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5646573', 'n_tokens_mistral': 899, 'n_tokens_neox': 897, 'n_words': 199}