From 057919e236a267753ae272dfacb23a17dc7d5bb0 Mon Sep 17 00:00:00 2001 From: Steven Irving Date: Mon, 1 Apr 2024 04:20:25 -0600 Subject: [PATCH] Add timestamps_format option to configuration file (#378) --- cmd/messages_text.go | 4 ++-- internal/config/config.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/messages_text.go b/cmd/messages_text.go index cd6b19f..2a11599 100644 --- a/cmd/messages_text.go +++ b/cmd/messages_text.go @@ -97,10 +97,10 @@ func (mt *MessagesText) createMessage(m discord.Message) { } func (mt *MessagesText) createHeader(w io.Writer, m discord.Message, isReply bool) { - time := m.Timestamp.Time().In(time.Local).Format(time.Kitchen) + time := m.Timestamp.Time().In(time.Local).Format(cfg.TimestampsFormat) if cfg.Timestamps && cfg.TimestampsBeforeAuthor { - fmt.Fprintf(w, "[::d]%7s[::-] ", time) + fmt.Fprintf(w, "[::d]%s[::-] ", time) } if isReply { diff --git a/internal/config/config.go b/internal/config/config.go index 5def224..11adf90 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,6 +3,7 @@ package config import ( "os" "path/filepath" + "time" "github.com/BurntSushi/toml" "github.com/ayn2op/discordo/internal/constants" @@ -13,6 +14,7 @@ type Config struct { Timestamps bool `toml:"timestamps"` TimestampsBeforeAuthor bool `toml:"timestamps_before_author"` + TimestampsFormat string `toml:"timestamps_format"` MessagesLimit uint8 `toml:"messages_limit"` @@ -28,6 +30,7 @@ func DefaultConfig() Config { Timestamps: false, TimestampsBeforeAuthor: false, + TimestampsFormat: time.Kitchen, MessagesLimit: 50, Editor: "default",