Skip to content

Commit

Permalink
fixed timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
hexahigh committed Oct 30, 2023
1 parent 938cbd3 commit be83bb4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"log"
"os"
"strconv"
"time"

_ "github.com/mattn/go-sqlite3"
)
Expand Down Expand Up @@ -82,7 +84,7 @@ var (

var channelName string

const version = "0.2"
const version = "0.2.1"

func main() {
flag.Parse()
Expand Down Expand Up @@ -130,11 +132,19 @@ func main() {

jsonMessages := make([]JsonMessage, 0)
for _, msg := range messages {
timestampMillis, err := strconv.ParseInt(msg.Timestamp, 10, 64)
if err != nil {
log.Fatal(err)
}

timestamp := time.Unix(0, timestampMillis*int64(time.Millisecond))

formattedTimestamp := timestamp.Format("2006-01-02T15:04:05.999-07:00")
jsonMsg := JsonMessage{
ID: msg.MessageID,
Type: "Default",
Timestamp: msg.Timestamp,
TimestampEdited: msg.EditTimestamp,
Timestamp: formattedTimestamp,
TimestampEdited: formattedTimestamp,
IsPinned: false,
Content: msg.Content,
Author: Author{
Expand Down

0 comments on commit be83bb4

Please sign in to comment.