<commit_before>package savvytodo.model.task;

import java.time.DateTimeException;
import java.time.LocalDateTime;

import savvytodo.commons.exceptions.IllegalValueException;
import savvytodo.commons.util.DateTimeUtil;
import savvytodo.commons.util.StringUtil;

/**
 * @author A0140016B
 *
 * Represents Task's DateTime in the task manager Guarantees: immutable;
 * is valid as declared in {@link #isValidEvent(String, String)} *
 */
public class DateTime implements Comparable<DateTime> {

    public String startValue;
    public String endValue;
    public String timestamp;

    private LocalDateTime start;
    private LocalDateTime end;

    public static final String MESSAGE_DATETIME_CONSTRAINTS = "Start date/time should not be after End date/time";

    private static final int COMPARE_TO_SMALLER = -1;
    private static final int COMPARE_TO_EQUAL = 0;
    private static final int COMPARE_TO_GREATER = 1;

    public static final String DATETIME_STRING_CONNECTOR = " = ";
    private static final String DATETIME_STRING_TO_STRING_CONNECTOR = " ~ ";
    public static final String[] DEFAULT_VALUES = {StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING};

    /**
     * Default constructor
     * @throws DateTimeException
     */
    public DateTime() throws IllegalValueException {
        this(DEFAULT_VALUES);
    }

    /**
     * Validates given DateTime.
     * If DateTime is NULL, means that the task is not an event
     * @throws IllegalValueException end date occurring before start date.
     */
    public DateTime(String startDateTime, String endDateTime) throws IllegalValueException {
        if (endDateTime != null && !endDateTime.isEmpty()) {
            this.end = LocalDateTime.parse(endDateTime.trim(), DateTimeUtil.DATE_FORMATTER);
            this.endValue = this.end.format(DateTimeUtil.DATE_STRING_FORMATTER);
        } else {
            this.endValue = endDateTime;
        }
        if (startDateTime != null && !startDateTime.isEmpty()) {
            this.start = LocalDateTime.parse(startDateTime.trim(), DateTimeUtil.DATE_FORMATTER);
            this.startValue = this.start.format(DateTimeUtil.DATE_STRING_FORMATTER);
            if (!isValidEvent(this.start, this.end)) {
                throw new IllegalValueException(MESSAGE_DATETIME_CONSTRAINTS);
            }
        } else {
            this.startValue = startDateTime;
        }
    }

    public DateTime(LocalDateTime startDateTime, LocalDateTime endDateTime) {
        assert (startDateTime != null && endDateTime != null);
        this.start = startDateTime;
        this.end = endDateTime;
        this.endValue = this.end.format(DateTimeUtil.DATE_STRING_FORMATTER);
        this.startValue = this.start.format(DateTimeUtil.DATE_STRING_FORMATTER);
    }

    /**
     * Constructor when given input as String array
     * @param dateTime
     * @throws IllegalValueException
     * @throws DateTimeException
     */
    public DateTime(String[] dateTime) throws DateTimeException, IllegalValueException {
        this(dateTime[0], dateTime[1]);
    }

    /**
     * Set timestamp if exists
     */
    private void setDateTimeStamp() {
        if (timestamp == null || timestamp.isEmpty()) {
            this.setAdd(LocalDateTime.now());
        } else {
            this.setAdd(LocalDateTime.parse(timestamp));
        }<commit_msg>Remove old timestamp in DataTime class<commit_after>package savvytodo.model.task;

import java.time.DateTimeException;
import java.time.LocalDateTime;

import savvytodo.commons.exceptions.IllegalValueException;
import savvytodo.commons.util.DateTimeUtil;
import savvytodo.commons.util.StringUtil;

/**
 * @author A0140016B
 *
 * Represents Task's DateTime in the task manager Guarantees: immutable;
 * is valid as declared in {@link #isValidEvent(String, String)} *
 */
public class DateTime implements Comparable<DateTime> {

    public String startValue;
    public String endValue;
    public String timestamp;

    private LocalDateTime start;
    private LocalDateTime end;

    public static final String MESSAGE_DATETIME_CONSTRAINTS = "Start date/time should not be after End date/time";

    private static final int COMPARE_TO_SMALLER = -1;
    private static final int COMPARE_TO_EQUAL = 0;
    private static final int COMPARE_TO_GREATER = 1;

    public static final String DATETIME_STRING_CONNECTOR = " = ";
    private static final String DATETIME_STRING_TO_STRING_CONNECTOR = " ~ ";
    public static final String[] DEFAULT_VALUES = {StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING};

    /**
     * Default constructor
     * @throws DateTimeException
     */
    public DateTime() throws IllegalValueException {
        this(DEFAULT_VALUES);
    }

    /**
     * Validates given DateTime.
     * If DateTime is NULL, means that the task is not an event
     * @throws IllegalValueException end date occurring before start date.
     */
    public DateTime(String startDateTime, String endDateTime) throws IllegalValueException {
        if (endDateTime != null && !endDateTime.isEmpty()) {
            this.end = LocalDateTime.parse(endDateTime.trim(), DateTimeUtil.DATE_FORMATTER);
            this.endValue = this.end.format(DateTimeUtil.DATE_STRING_FORMATTER);
        } else {
            this.endValue = endDateTime;
        }
        if (startDateTime != null && !startDateTime.isEmpty()) {
            this.start = LocalDateTime.parse(startDateTime.trim(), DateTimeUtil.DATE_FORMATTER);
            this.startValue = this.start.format(DateTimeUtil.DATE_STRING_FORMATTER);
            if (!isValidEvent(this.start, this.end)) {
                throw new IllegalValueException(MESSAGE_DATETIME_CONSTRAINTS);
            }
        } else {
            this.startValue = startDateTime;
        }
    }

    public DateTime(LocalDateTime startDateTime, LocalDateTime endDateTime) {
        assert (startDateTime != null && endDateTime != null);
        this.start = startDateTime;
        this.end = endDateTime;
        this.endValue = this.end.format(DateTimeUtil.DATE_STRING_FORMATTER);
        this.startValue = this.start.format(DateTimeUtil.DATE_STRING_FORMATTER);
    }

    /**
     * Constructor when given input as String array
     * @param dateTime
     * @throws IllegalValueException
     * @throws DateTimeException
     */
    public DateTime(String[] dateTime) throws DateTimeException, IllegalValueException {
        this(dateTime[0], dateTime[1]);
{'fraction_non_alphanumeric': 0.08788303002022087, 'fraction_numerical': 0.003733084461035931, 'mean_word_length': 3.156431803490627, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7480262', 'n_tokens_mistral': 1733, 'n_tokens_neox': 1690, 'n_words': 433}