feat: timestamps now respect local timezone by default (#177)
Closes #154
This commit is contained in:
parent
05fb80f889
commit
7813d7914d
2 changed files with 8 additions and 1 deletions
|
|
@ -40,6 +40,7 @@ type Config struct {
|
|||
Mouse bool `toml:"mouse"`
|
||||
Timestamps bool `toml:"timestamps"`
|
||||
MessagesLimit int `toml:"messages_limit"`
|
||||
Timezone string `toml:"timezone"`
|
||||
AttachmentDownloadsDir string `toml:"attachment_downloads_dir"`
|
||||
Identify IdentifyConfig `toml:"identify"`
|
||||
Theme ThemeConfig `toml:"theme"`
|
||||
|
|
@ -51,6 +52,7 @@ func New() *Config {
|
|||
Mouse: true,
|
||||
Timestamps: false,
|
||||
MessagesLimit: 50,
|
||||
Timezone: "Local",
|
||||
AttachmentDownloadsDir: UserDownloadsDir(),
|
||||
Identify: IdentifyConfig{
|
||||
UserAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36",
|
||||
|
|
|
|||
|
|
@ -24,8 +24,13 @@ func buildMessage(app *App, m *astatine.Message) []byte {
|
|||
buildReferencedMessage(&b, m.ReferencedMessage, app.Session.State.User.ID)
|
||||
|
||||
if app.Config.Timestamps {
|
||||
loc, err := time.LoadLocation(app.Config.Timezone)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
b.WriteString("[::d]")
|
||||
b.WriteString(m.Timestamp.Format(time.Stamp))
|
||||
b.WriteString(m.Timestamp.In(loc).Format(time.Stamp))
|
||||
b.WriteString("[::-]")
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue