37 lines
871 B
Go
37 lines
871 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
func main() {
|
|
if err := InitDB("data"); err != nil {
|
|
log.Fatalf("Failed to initialize BadgerDB: %v", err)
|
|
}
|
|
defer CloseDB()
|
|
|
|
// Get the current datetime
|
|
now := time.Now()
|
|
// Set the start date used for opening the current month instead of 1/1/1970
|
|
start := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, time.UTC)
|
|
// This gets the weekday of the first of the month so that we have the correct day with the correct date
|
|
offset := int(start.Weekday())
|
|
p := tea.NewProgram(model{
|
|
year: now.Year(),
|
|
monthIndex: int(now.Month()) - 1,
|
|
cursorRow: offset / numCols,
|
|
cursorCol: offset % numCols,
|
|
startOffset: offset,
|
|
mode: monthView,
|
|
})
|
|
if err := p.Start(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|