<commit_before>package tars.logic.parser;

import java.time.DateTimeException;
import static tars.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import tars.commons.core.Messages;
import tars.commons.util.DateTimeUtil;
import tars.commons.util.StringUtil;
import tars.logic.commands.Command;
import tars.logic.commands.FreeCommand;
import tars.logic.commands.IncorrectCommand;
import tars.model.task.DateTime;
import tars.model.task.DateTime.IllegalDateException;


/**
 * Free command parser
 * 
 * @@author A0124333U
 *
 */
public class FreeCommandParser extends CommandParser {

    @Override
    public Command prepareCommand(String args) {
        args = args.trim();

        if (args.isEmpty()) {
            return new IncorrectCommand(String.format(
                    MESSAGE_INVALID_COMMAND_FORMAT, FreeCommand.MESSAGE_USAGE));
        }

        String[] dateTimeStringArray = {StringUtil.EMPTY_STRING};

        try {
            dateTimeStringArray = DateTimeUtil.parseStringToDateTime(args);
        } catch (DateTimeException dte) {
            return new IncorrectCommand(String.format(
                    MESSAGE_INVALID_COMMAND_FORMAT, FreeCommand.MESSAGE_USAGE));
        }

        if (!dateTimeStringArray[0].isEmpty()) {
            return new IncorrectCommand(
                    FreeCommand.MESSAGE_DATE_RANGE_DETECTED);
        } else {
            try {
                return new FreeCommand(new DateTime(dateTimeStringArray[0],
                        dateTimeStringArray[1]));
            } catch (DateTimeException dte) {
                return new IncorrectCommand(Messages.MESSAGE_INVALID_DATE);
            } catch (IllegalDateException ide) {
                return new IncorrectCommand(Messages.MESSAGE_INVALID_DATE);
            }
        }
    }

}<commit_msg>Remove magic numbers in FreeCommandParser<commit_after>package tars.logic.parser;

import java.time.DateTimeException;
import static tars.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import tars.commons.core.Messages;
import tars.commons.util.DateTimeUtil;
import tars.commons.util.StringUtil;
import tars.logic.commands.Command;
import tars.logic.commands.FreeCommand;
import tars.logic.commands.IncorrectCommand;
import tars.model.task.DateTime;
import tars.model.task.DateTime.IllegalDateException;


/**
 * Free command parser
 * 
 * @@author A0124333U
 *
 */
public class FreeCommandParser extends CommandParser {
    
    public static final int FIRST_DATETIME_INDEX = 0;
    public static final int SECOND_DATETIME_INDEX = 1;

    @Override
    public Command prepareCommand(String args) {
        args = args.trim();

        if (args.isEmpty()) {
            return new IncorrectCommand(String.format(
                    MESSAGE_INVALID_COMMAND_FORMAT, FreeCommand.MESSAGE_USAGE));
        }

        String[] dateTimeStringArray = {StringUtil.EMPTY_STRING};

        try {
            dateTimeStringArray = DateTimeUtil.parseStringToDateTime(args);
        } catch (DateTimeException dte) {
            return new IncorrectCommand(String.format(
                    MESSAGE_INVALID_COMMAND_FORMAT, FreeCommand.MESSAGE_USAGE));
        }

        if (!dateTimeStringArray[FIRST_DATETIME_INDEX].isEmpty()) {
            return new IncorrectCommand(
                    FreeCommand.MESSAGE_DATE_RANGE_DETECTED);
        } else {
            try {
                return new FreeCommand(new DateTime(dateTimeStringArray[FIRST_DATETIME_INDEX],
                        dateTimeStringArray[SECOND_DATETIME_INDEX]));
            } catch (DateTimeException dte) {
                return new IncorrectCommand(Messages.MESSAGE_INVALID_DATE);
            } catch (IllegalDateException ide) {
                return new IncorrectCommand(Messages.MESSAGE_INVALID_DATE);
            }
        }
    }

}
{'fraction_non_alphanumeric': 0.0822420115243583, 'fraction_numerical': 0.00497642744892614, 'mean_word_length': 2.7222222222222223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5896699', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1008, 'n_words': 188}