<commit_before><?php

/**
 * This file is part of the Grido (http://grido.bugyik.cz)
 *
 * Copyright (c) 2011 <NAME> (http://petr.bugyik.cz)
 *
 * For the full copyright and license information, please view
 * the file license.md that was distributed with this source code.
 */

namespace Grido\Components\Columns;

/**
 * Text column.
 *
 * @package     Grido
 * @subpackage  Components\Columns
 * @author      <NAME>
 *
 * @property-write string $dateFormat
 */
class Date extends Text
{
    const FORMAT_TEXT = 'd M Y';
    const FORMAT_DATE = 'd.m.Y';
    const FORMAT_DATETIME = 'd.m.Y H:i:s';

    /** @var string */
    protected $dateFormat = self::FORMAT_DATE;

    /**
     * @param string $format
     * @return Date
     */
    public function setDateFormat($format)
    {
        $this->dateFormat = $format;
        return $this;
    }

    /**
     * @param $value
     * @return string
     */
    protected function formatValue($value)
    {
        return $value ? date($this->dateFormat, strtotime($value)) : NULL;
    }
}<commit_msg>Columns\Date: Fixed rendering for export [Issue #17]<commit_after><?php

/**
 * This file is part of the Grido (http://grido.bugyik.cz)
 *
 * Copyright (c) 2011 <NAME> (http://petr.bugyik.cz)
 *
 * For the full copyright and license information, please view
 * the file license.md that was distributed with this source code.
 */

namespace Grido\Components\Columns;

/**
 * Text column.
 *
 * @package     Grido
 * @subpackage  Components\Columns
 * @author      <NAME>
 *
 * @property-write string $dateFormat
 */
class Date extends Text
{
    const FORMAT_TEXT = 'd M Y';
    const FORMAT_DATE = 'd.m.Y';
    const FORMAT_DATETIME = 'd.m.Y H:i:s';

    /** @var string */
    protected $dateFormat = self::FORMAT_DATE;

    /**
     * @param string $format
     * @return Date
     */
    public function setDateFormat($format)
    {
        $this->dateFormat = $format;
        return $this;
    }

    /**
     * @param $value
     * @return string
     */
    protected function formatValue($value)
    {
        return $value ? date($this->dateFormat, strtotime($value)) : NULL;
    }

    public function renderExport($row)
    {
        $value = $this->getValue($row);
        return $value instanceof \DateTime
            ? $value->format($this->dateFormat)
            : $this->formatValue($value);
    }
}
{'fraction_non_alphanumeric': 0.13755274261603376, 'fraction_numerical': 0.004219409282700422, 'mean_word_length': 2.4970501474926254, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '5810251', 'n_tokens_mistral': 761, 'n_tokens_neox': 741, 'n_words': 199}