<commit_before>package history_entries

import (
	"errors"
	"fmt"
	"time"

	"../environments"
	"../utils"
)

const (
	MARK_HAS_HISTORY    = '*'
	MARK_HAS_NO_HISTORY = ' '
)

type HistoryEntry struct {
	number     uint
	command    string
	timestamp  int
	hasHistory bool
}

func (he HistoryEntry) GetNumber() (uint, error) {
	if he.number == 0 {
		return 0, errors.New("Number is not set yet")
	}
	return he.number, nil
}

func (he HistoryEntry) GetCommand() (string, error) {
	if he.command == "" {
		return "", errors.New("Command is not set yet")
	}
	return he.command, nil
}

func (he HistoryEntry) GetTimestamp() (int, error) {
	if he.timestamp == 0 {
		return 0, errors.New("Timestamp is not set yet")
	}
	return he.timestamp, nil
}

func (he HistoryEntry) GetTime() (*time.Time, error) {
	timestamp, err := he.GetTimestamp()
	if err != nil {
		return nil, err
	}
	return utils.ConvertTimestamp(timestamp), nil
}

func (he HistoryEntry) GetFormattedTime(env *environments.Environment) (string, error) {
	timestamp, err := he.GetTimestamp()
	if err != nil {
		return "", err
	}
	return env.FormatTimeStamp(timestamp)
}

func (he HistoryEntry) HasHistory() bool {
	return he.hasHistory
}

func (he HistoryEntry) ToString(env *environments.Environment) string {
	command, _ := he.GetCommand()
	number, _ := he.GetNumber()

	timestamp := ""
	if formattedTimestamp, err := he.GetFormattedTime(env); err == nil {
		timestamp = "\t" + formattedTimestamp
	}

	history := MARK_HAS_NO_HISTORY
	if he.HasHistory() {
		history = MARK_HAS_NO_HISTORY
	}

	return fmt.Sprintf("!%d %c%s\t%s", number, history, timestamp, command)
}<commit_msg>Small fix<commit_after>package history_entries

import (
	"errors"
	"fmt"
	"time"

	"../environments"
	"../utils"
)

const (
	MARK_HAS_HISTORY    = '*'
	MARK_HAS_NO_HISTORY = ' '
)

type HistoryEntry struct {
	number     uint
	command    string
	timestamp  int
	hasHistory bool
}

func (he HistoryEntry) GetNumber() (uint, error) {
	if he.number == 0 {
		return 0, errors.New("Number is not set yet")
	}
	return he.number, nil
}

func (he HistoryEntry) GetCommand() (string, error) {
	if he.command == "" {
		return "", errors.New("Command is not set yet")
	}
	return he.command, nil
}

func (he HistoryEntry) GetTimestamp() (int, error) {
	if he.timestamp == 0 {
		return 0, errors.New("Timestamp is not set yet")
	}
	return he.timestamp, nil
}

func (he HistoryEntry) GetTime() (*time.Time, error) {
	timestamp, err := he.GetTimestamp()
	if err != nil {
		return nil, err
	}
	return utils.ConvertTimestamp(timestamp), nil
}

func (he HistoryEntry) GetFormattedTime(env *environments.Environment) (string, error) {
	timestamp, err := he.GetTimestamp()
	if err != nil {
		return "", err
	}
	return env.FormatTimeStamp(timestamp)
}

func (he HistoryEntry) HasHistory() bool {
	return he.hasHistory
}

func (he HistoryEntry) ToString(env *environments.Environment) string {
	command, _ := he.GetCommand()
	number, _ := he.GetNumber()

	timestamp := ""
	if formattedTimestamp, err := he.GetFormattedTime(env); err == nil {
		timestamp = "\t" + formattedTimestamp
	}

	history := MARK_HAS_NO_HISTORY
	if he.HasHistory() {
		history = MARK_HAS_HISTORY
	}

	return fmt.Sprintf("!%d %c%s\t%s", number, history, timestamp, command)
}
{'fraction_non_alphanumeric': 0.1381639545594105, 'fraction_numerical': 0.002456248081056187, 'mean_word_length': 4.090625, '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': '4376935', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1128, 'n_words': 305}