<commit_before>/*
 * https://github.com/arashm/JDate
 * @author: <NAME>
 */

import Converter from './converter';
import * as helpers from './helpers';

export default class JDate {
  constructor(...args) {
    if (Array.isArray(args[0]) || args[0] instanceof Date) {
      [this.input] = args;
    } else if (args.length === 3) {
      this.input = args;
    } else if (!args.length) {
      this.input = new Date();
    } else {
      throw new Error('Unexpected input');
    }

    if (Array.isArray(this.input)) {
      this.date = this.input.map((num) => parseInt(num, 10));
      this._d = this.toGregorian();
    } else if (this.input instanceof Date) {
      this._d = this.input;
      this.date = JDate.toJalali(this.input);
    }
  }

  /*
   * Coverts a Gregorian date to Jalali date
   *
   * @params {Date} date
   * @return {Array}
   */
  static toJalali(date) {
    const julianDate = Converter.gregorianToJulian(
      date.getFullYear(),
      date.getMonth() + 1,
      date.getDate()
    );
    const jdate = Converter.julianToPersian(julianDate);

    return jdate;
  }

  // eslint-disable-next-line camelcase
  static to_jalali(date) { return JDate.toJalali(date); }

  /*
   * converts a Jalali date to Gregorian
   *
   * @params {Number} year
   * @params {Number} month
   * @params {Number} day
   * @return {Date}
   */
  static toGregorian(year, month, day) {
    const gdate = Converter.julianToGregorian(
      Converter.persianToJulian(year, month, day)
    );

    return new Date(gdate[0], gdate[1] - 1, gdate[2]);
  }

  // eslint-disable-next-line camelcase
  static to_gregorian(year, month, day) { return JDate.toGregorian(year, month, day); }<commit_msg>Convert strings to number for toGregorian<commit_after>/*
 * https://github.com/arashm/JDate
 * @author: <NAME>
 */

import Converter from './converter';
import * as helpers from './helpers';

export default class JDate {
  constructor(...args) {
    if (Array.isArray(args[0]) || args[0] instanceof Date) {
      [this.input] = args;
    } else if (args.length === 3) {
      this.input = args;
    } else if (!args.length) {
      this.input = new Date();
    } else {
      throw new Error('Unexpected input');
    }

    if (Array.isArray(this.input)) {
      this.date = this.input.map((num) => parseInt(num, 10));
      this._d = this.toGregorian();
    } else if (this.input instanceof Date) {
      this._d = this.input;
      this.date = JDate.toJalali(this.input);
    }
  }

  /*
   * Coverts a Gregorian date to Jalali date
   *
   * @params {Date} date
   * @return {Array}
   */
  static toJalali(date) {
    const julianDate = Converter.gregorianToJulian(
      date.getFullYear(),
      date.getMonth() + 1,
      date.getDate()
    );
    const jdate = Converter.julianToPersian(julianDate);

    return jdate;
  }

  // eslint-disable-next-line camelcase
  static to_jalali(date) { return JDate.toJalali(date); }

  /*
   * converts a Jalali date to Gregorian
   *
   * @params {Number} year
   * @params {Number} month
   * @params {Number} day
   * @return {Date}
   */
  static toGregorian(year, month, day) {
    const gdate = Converter.julianToGregorian(
      Converter.persianToJulian(year, month, day)
    );

    return new Date(+gdate[0], +gdate[1] - 1, +gdate[2]);
  }

  // eslint-disable-next-line camelcase
  static to_gregorian(year, month, day) { return JDate.toGregorian(year, month, day); }
{'fraction_non_alphanumeric': 0.14703303127740427, 'fraction_numerical': 0.005846243788365975, 'mean_word_length': 2.7439824945295404, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '5672461', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1193, 'n_words': 273}