<commit_before>namespace Jalali;

class Date
{
    /**
     * Length of a year
     * Calculated by Khayam is 365.2422 days (approx.);
     * but as the years are getting shorter the new value
     * (valid from year 1380 Per./2000 A.D.) is used instead.
     *
     * @access protected
     * @var double
     */
    protected static $khayamYear = 365.24218956;

    /**
     * Count of days at the end of each Persian month
     *
     * @access protected
     * @var array
     */
    protected mountCounter = [
        0, 31, 62, 93, 124, 155,
        186, 216, 246, 276, 306, 336
    ];

    public function makeDateTime(hour, minute, second, month, day, year)
    {
        int timestamp;
        int dayOfYear;
        var datetime;

        let timestamp = second + minute * 60 + hour * 60 * 60;

        let dayOfYear = (day + this->mountCounter[$month - 1]);

        if (year < 100) {
            let year = year + 1300;
        }

        let year = year - 1348;

        let day = dayOfYear + round(( self::khayamYear * year), 0) - 287;
        let timestamp = timestamp + day * 86400;

        let datetime = new \DateTime();
        datetime->setTimestamp(timestamp);
        return datetime;
    }

}<commit_msg>fix mktime functionality with <= 1348 years<commit_after>namespace Jalali;

class Date
{
    /**
     * Length of a year
     * Calculated by Khayam is 365.2422 days (approx.);
     * but as the years are getting shorter the new value
     * (valid from year 1380 Per./2000 A.D.) is used instead.
     *
     * @access protected
     * @var double
     */
    const KHAYAM_YEAR = 365.24218956;

    /**
     * Count of days at the end of each Persian month
     *
     * @access protected
     * @var array
     */
    protected mountCounter = [
        0, 31, 62, 93, 124, 155,
        186, 216, 246, 276, 306, 336
    ];

    public function mktime(year, month, day, hour=0, minute=0, second=0)
    {
        float timestamp;

        let timestamp = second + minute * 60 + hour * 60 * 60;
        let year = year - 1348;
        let day = this->mountCounter[month - 1] + day + round(( self::KHAYAM_YEAR * year), 0) - 287;
        let timestamp = timestamp + day * 86400;

        return timestamp;
    }

}
{'fraction_non_alphanumeric': 0.10683951721054985, 'fraction_numerical': 0.07510058113544926, 'mean_word_length': 1.9140625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '5782655', 'n_tokens_mistral': 831, 'n_tokens_neox': 670, 'n_words': 241}