You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

45 lines
805 B

package main
import (
"database/sql"
"fmt"
"log"
"time"
"github.com/joho/godotenv"
)
func getNewest() {
godotenv.Load()
var timestamps []int
db, err := sql.Open("sqlite3", opt.DB+".db")
if err != nil {
log.Fatal(err)
}
defer db.Close()
row, err := db.Query("SELECT created FROM posts ORDER BY created DESC LIMIT 1") //get newest timestamp
if err != nil {
log.Fatalln(err)
}
defer row.Close()
for row.Next() {
var createdAt int
row.Scan(&createdAt)
timestamps = append(timestamps, createdAt)
}
calcDiff(timestamps)
}
func calcDiff(timestamp []int) {
fmt.Println(timestamp[0])
now := time.Now()
thirtyMinutes := time.Minute * time.Duration(30)
futureTime := now.Add(thirtyMinutes)
fmt.Println("30 minutes from now will be : ", futureTime.Unix())
}
func timing() {
}