<commit_before>import React, { useEffect } from "react";
import { format, parseISO, isBefore } from "date-fns";
import { useAppReducer } from "../AppContext";
import styles from "./TodoDate.module.scss";

// Current date at the top of the page
function TodoDate() {
  let dispatch = useAppReducer();
  const date = {
    day: format(new Date(), "d"),
    month: format(new Date(), "MMM"),
    year: format(new Date(), "y"),
    weekday: format(new Date(), "EEEE")
  };

  useEffect(() => {
    setDate();
    // eslint-disable-next-line
  }, []);

  function setDate() {
    const local = localStorage.getItem("date");
    dispatch({ type: "SET_DATE", date });
    checkDate(local);
  }

  function checkDate(local) {
    let currentDate = parseISO(format(new Date(), "yyyy-MM-dd"));
    let localDate = parseISO(local);
    if (local !== null && isBefore(localDate, currentDate)) {
      dispatch({ type: "RESET_ALL" });
    }
    localStorage.setItem("date", currentDate);
  }

  return (
    <div className={styles.date}>
      <div className={styles.calendar}>
        <div className={styles.day}>{date.day}</div>
        <div className={styles.my}>
          <div className={styles.month}>{date.month}</div>
          <div className={styles.year}>{date.year}</div>
        </div>
      </div>
      <div className="today">{date.weekday}</div><commit_msg>Fix reset bug<commit_after>import React, { useEffect } from "react";
import { format, parseISO, isBefore } from "date-fns";
import { useAppReducer } from "../AppContext";
import styles from "./TodoDate.module.scss";

// Current date at the top of the page
function TodoDate() {
  let dispatch = useAppReducer();
  const date = {
    day: format(new Date(), "d"),
    month: format(new Date(), "MMM"),
    year: format(new Date(), "y"),
    weekday: format(new Date(), "EEEE")
  };

  useEffect(() => {
    setDate();
    // eslint-disable-next-line
  }, []);

  function setDate() {
    const local = localStorage.getItem("date");
    dispatch({ type: "SET_DATE", date });
    checkDate(local);
  }

  function checkDate(local) {
    const currentDate = format(new Date(), "yyyy-MM-dd");
    const currentDateToCompare = parseISO(currentDate);
    const localDateToCompare = parseISO(local);

    if (local !== null && isBefore(localDateToCompare, currentDateToCompare)) {
      dispatch({ type: "RESET_ALL" });
      localStorage.setItem("date", currentDate);
    }
  }

  return (
    <div className={styles.date}>
      <div className={styles.calendar}>
        <div className={styles.day}>{date.day}</div>
        <div className={styles.my}>
          <div className={styles.month}>{date.month}</div>
          <div className={styles.year}>{date.year}</div>
        </div>
      </div>
      <div className="today">{date.weekday}</div>
{'fraction_non_alphanumeric': 0.17441029306647604, 'fraction_numerical': 0.0, 'mean_word_length': 3.306153846153846, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, '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': '3920169', 'n_tokens_mistral': 882, 'n_tokens_neox': 864, 'n_words': 204}