<commit_before>import _ from 'lodash'


export default class {

  constructor(y,m,d,h=0,mm=0) {
    this.months = ["jan", "feb", "mar", "apr", "may", "june", "july", "aug", "sep", "oct", "nov", "dec"];
    this.days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    this.except = [];

    if (!y) {
      let now = new Date()
      y = now.getFullYear()
      m = this.months[now.getMonth()]
    }

    if (typeof Number(m) === 'number')
      m = this.months[m]
    this.changeDate(y,m,d,h,mm)
  }

  setException(except) {
    this.except = except;
  }

  changeDate(y,m,d,h,mm) {
    if (typeof m === 'number')
      m = this.months[m]
    this.date = this.linkHelper(y,m,d,h,mm)
  }

  getEvents(line, events, withHour=false) {
    let allevents = events.filter( evt  => {
      let {start, end} = this.getLimit(line, evt, withHour)
      if (start && end) {
        evt.cell = {start: start.col, end: end.col}
        return evt;
      }
    })

    return allevents
      .sort( (a, b) => b.cell.start - a.cell.start )
      .sort( (a, b) => b.cell.end - b.cell.start - (a.cell.end - a.cell.start) )
  }

  matrix(view='month') {
    let {y,m,d,h,mm} = this.date
    var {rows, cols} = this.getRange(6,7)
      , {start, next, date} = this.getInitDates()
      , days = next.getDate()
      , months = []
      , weeks
      , day
      , tmp
      , currentWeek
      , cellDate

    _.each(rows, (row) => {
      weeks = [];
      _.each(cols, (col) => {
        if (row === 0) {
          day = col - start.getDay() + 1
          tmp = (col < start.getDay()
              ? -(new Date(y, m, -(start.getDay() - 1 - col)).getDate())
              : day)
        } else {
          day = _.last(months)[6].day + col + 1
          tmp = (day <= days ? day : -(day - days))
        }

        //adjust month and year
        let yearTmp = Number(y)
          , monthTmp = Number(m)
        if (tmp < -20) monthTmp -= 1
        else if (tmp < 0) monthTmp += 1
        if (monthTmp < 0) {
          monthTmp = 11;
          yearTmp -= 1;
        } else if (monthTmp > 11) {
          monthTmp = 0;
          yearTmp += 1;
        }

        cellDate = new Date(yearTmp, monthTmp , Math.abs(tmp))
        weeks.push({
          date: cellDate,
          day: tmp,
          week: cellDate.getWeek(),
          month: cellDate.getMonth(),
          year: cellDate.getFullYear(),
          col: col,
          row: row,
          disabled: this.checkExcept(cellDate, view)
        })

      });
      if (view === 'week' && cellDate.getWeek() === date.getWeek() && !currentWeek)
        currentWeek = weeks

      if (!row || weeks[0].day > 0)
        months.push(weeks)

    });

    if (currentWeek) {
      let weekHour = []
      _.each(currentWeek, (item) => {
        let dayHour = []
        _.range(0, 24).map((hour) => {
          let date = new Date(item.year, item.month , Math.abs(item.day), hour)
            , check = this.checkExcept(date, view)
          dayHour.push(_.assign({}, item, {hour}, {col: hour}, {date}, {disabled: check}))
        })
        weekHour.push(dayHour)
      })
      return weekHour;
    }
    return months;
  }

  checkExcept(date, view) {
    var ret = false;
    for(let i=0, len=this.except.length; i<len; i++) {
      switch(typeof this.except[i]) {
        case 'string':
          if (date.getDay() === this.days.indexOf(this.except[i]))
            ret = true;
          break;
        case 'object':
          switch(typeof this.except[i].start) {
            case 'number':
              if (view === 'week' && date.getHours() >= this.except[i].start && date.getHours() <= this.except[i].end)
                ret = true;
              break;
            default:
              if (date >= this.except[i].start && date <= this.except[i].end)
                ret = true;
              break;
          }
          if (date.getDay() === this.days.indexOf(this.except[i]))
            ret = true;
          break;
        default:
          if (date == this.except[i])
            ret = true;
          break;

      }
    }
    return ret;
  }

  getRange(rows, cols) {
    return {
      rows: _.range(0, rows),
      cols: _.range(0, cols)
    }
  }

  getInitDates() {
    return {
      start: new Date(this.date.y, this.date.m),
      next: new Date(this.date.y, this.date.m + 1, 0),
      date: new Date(this.date.y, this.date.m, this.date.d)
    }
  }

  getDays() {
    return this.days;
  }

  getToday(withDay) {
    let today = new Date()
    return this.linkHelper(today.getFullYear(), today.getMonth(), withDay ? today.getDate() : null);<commit_msg>exception: fix check<commit_after>import _ from 'lodash'


export default class {

  constructor(y,m,d,h=0,mm=0) {
    this.months = ["jan", "feb", "mar", "apr", "may", "june", "july", "aug", "sep", "oct", "nov", "dec"];
    this.days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    this.except = [];

    if (!y) {
      let now = new Date()
      y = now.getFullYear()
      m = this.months[now.getMonth()]
    }

    if (typeof Number(m) === 'number')
      m = this.months[m]
    this.changeDate(y,m,d,h,mm)
  }

  setException(except) {
    this.except = except;
  }

  changeDate(y,m,d,h,mm) {
    if (typeof m === 'number')
      m = this.months[m]
    this.date = this.linkHelper(y,m,d,h,mm)
  }

  getEvents(line, events, withHour=false) {
    let allevents = events.filter( evt  => {
      let {start, end} = this.getLimit(line, evt, withHour)
      if (start && end) {
        evt.cell = {start: start.col, end: end.col}
        return evt;
      }
    })

    return allevents
      .sort( (a, b) => b.cell.start - a.cell.start )
      .sort( (a, b) => b.cell.end - b.cell.start - (a.cell.end - a.cell.start) )
  }

  matrix(view='month') {
    let {y,m,d,h,mm} = this.date
    var {rows, cols} = this.getRange(6,7)
      , {start, next, date} = this.getInitDates()
      , days = next.getDate()
      , months = []
      , weeks
      , day
      , tmp
      , currentWeek
      , cellDate

    _.each(rows, (row) => {
      weeks = [];
      _.each(cols, (col) => {
        if (row === 0) {
          day = col - start.getDay() + 1
          tmp = (col < start.getDay()
              ? -(new Date(y, m, -(start.getDay() - 1 - col)).getDate())
              : day)
        } else {
          day = _.last(months)[6].day + col + 1
          tmp = (day <= days ? day : -(day - days))
        }

        //adjust month and year
        let yearTmp = Number(y)
          , monthTmp = Number(m)
        if (tmp < -20) monthTmp -= 1
        else if (tmp < 0) monthTmp += 1
        if (monthTmp < 0) {
          monthTmp = 11;
          yearTmp -= 1;
        } else if (monthTmp > 11) {
          monthTmp = 0;
          yearTmp += 1;
        }

        cellDate = new Date(yearTmp, monthTmp , Math.abs(tmp), h)
        weeks.push({
          date: cellDate,
          day: tmp,
          week: cellDate.getWeek(),
          month: cellDate.getMonth(),
          year: cellDate.getFullYear(),
          col: col,
          row: row,
          disabled: this.checkExcept(cellDate, view)
        })

      });
      if (view === 'week' && cellDate.getWeek() === date.getWeek() && !currentWeek)
        currentWeek = weeks

      if (!row || weeks[0].day > 0)
        months.push(weeks)

    });

    if (currentWeek) {
      let weekHour = []
      _.each(currentWeek, (item) => {
        let dayHour = []
        _.range(0, 24).map((hour) => {
          let date = new Date(item.year, item.month , Math.abs(item.day), hour)
            , check = this.checkExcept(date, view)
          dayHour.push(_.assign({}, item, {hour}, {col: hour}, {date}, {disabled: check}))
        })
        weekHour.push(dayHour)
      })
      return weekHour;
    }
    return months;
  }

  checkExcept(date, view) {
    var ret = false;
    for(let i=0, len=this.except.length; i<len; i++) {
      switch(typeof this.except[i]) {
        case 'string':
          if (date.getDay() === this.days.indexOf(this.except[i]))
            ret = true;
          break;
        case 'object':
          switch(typeof this.except[i].start) {
            case 'number':
              if (view === 'week' && date.getHours() >= this.except[i].start && date.getHours() <= this.except[i].end)
                ret = true;
              break;
            case 'object':
              if (date >= this.except[i].start && date <= this.except[i].end)
                ret = true;
              break;
            default:
              if (date.toString() === this.except[i].toString())
                ret = true;
              break;
          }
          if (date.getDay() === this.days.indexOf(this.except[i]))
            ret = true;
          break;
        default:
          if (date.toString() === this.except[i].toString())
            ret = true;
          break;

      }
    }
    return ret;
  }

  getRange(rows, cols) {
    return {
      rows: _.range(0, rows),
      cols: _.range(0, cols)
    }
  }

  getInitDates() {
    return {
      start: new Date(this.date.y, this.date.m),
      next: new Date(this.date.y, this.date.m + 1, 0),
      date: new Date(this.date.y, this.date.m, this.date.d)
    }
  }

  getDays() {
    return this.days;
  }

  getToday(withDay) {
    let today = new Date()
    return this.linkHelper(today.getFullYear(), today.getMonth(), withDay ? today.getDate() : null);
{'fraction_non_alphanumeric': 0.1712008501594049, 'fraction_numerical': 0.006801275239107333, 'mean_word_length': 1.7286169904320092, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '3926243', 'n_tokens_mistral': 3353, 'n_tokens_neox': 3221, 'n_words': 714}