All quotes now use UTC time.
MODIFY
times/times.go
times/times.go
@@ -7,19 +7,22 @@ import (
"github.com/Bios-Marcel/cordless/config"
)
-// TimeToString formats a time to a string depending on the users settings.
+// TimeToLocalString formats a time to a string depending on the users settings.
// The time will first be converted into a local time.
+func TimeToLocalString(time *time.Time) string {
+ localTime := time.Local()
+ return TimeToString(&localTime)
+}
+
+// TimeToString formats a time to a string depending on the users settings.
func TimeToString(time *time.Time) string {
if config.GetConfig().Times == config.NoTime {
return ""
}
-
- localTime := time.Local()
if config.GetConfig().Times == config.HourMinuteAndSeconds {
- return fmt.Sprintf("%02d:%02d:%02d", localTime.Hour(), localTime.Minute(), localTime.Second())
+ return fmt.Sprintf("%02d:%02d:%02d", time.Hour(), time.Minute(), time.Second())
} else if config.GetConfig().Times == config.HourAndMinute {
- return fmt.Sprintf("%02d:%02d", localTime.Hour(), localTime.Minute())
+ return fmt.Sprintf("%02d:%02d", time.Hour(), time.Minute())
}
-
return ""
}

MODIFY
ui/chatview.go
ui/chatview.go
@@ -622,7 +622,7 @@ func messagePartsToColouredString(timestamp discordgo.Timestamp, author, message
time, parseError := timestamp.Parse()
var timeCellText string
if parseError == nil {
- timeCellText = times.TimeToString(&time)
+ timeCellText = times.TimeToLocalString(&time)
}
return fmt.Sprintf("[gray]%s %s [white]%s[\"\"][\"\"]", timeCellText, author, message)

MODIFY
ui/window.go
ui/window.go
@@ -864,7 +864,13 @@ func (window *Window) IsCursorInsideCodeBlock() bool {
func (window *Window) insertQuoteOfMessage(message *discordgo.Message) {
time, parseError := message.Timestamp.Parse()
- if parseError == nil {
+ if parseError != nil {
+ return
+ }
+
+ // All quotes should be UTC.
+ time = time.UTC()
+
currentContent := strings.TrimSpace(window.messageInput.GetText())
username := message.Author.Username
if message.GuildID != "" {
@@ -878,14 +884,13 @@ func (window *Window) insertQuoteOfMessage(message *discordgo.Message) {
}
quotedMessage := strings.ReplaceAll(message.ContentWithMentionsReplaced(), "\n", "\n> ")
- quotedMessage = fmt.Sprintf("> **%s** %s:\n> %s\n", username, times.TimeToString(&time), quotedMessage)
+ quotedMessage = fmt.Sprintf("> **%s** %s UTC:\n> %s\n", username, times.TimeToString(&time), quotedMessage)
if currentContent != "" {
quotedMessage = quotedMessage + currentContent
}
window.messageInput.SetText(quotedMessage)
window.app.SetFocus(window.messageInput.GetPrimitive())
}
-}
func (window *Window) TrySendMessage(targetChannel *discordgo.Channel, message string) {
if targetChannel == nil {

All quotes now use UTC time.