Files
gmh01 7614e79d12 refactor: rewrite backend in Go, replacing Python FastAPI
Port the FastAPI backend to Go 1.26, preserving all API functionality:
- auth (register/login/guest/logout/profile/history) with JWT + bcrypt
- scripts (list/detail) backed by embedded sample_data.json
- games (create/join/start/chat/phase/clue/vote/state/replay) + WebSocket
- rule-based NPC agent plus DeepSeek/Ollama AI backends
- SQLite persistence via modernc.org/sqlite (pure Go, no cgo)

Frontend and documents are unchanged.
2026-08-03 11:39:53 +08:00

26 lines
513 B
Go

package util
import "time"
const PyTimeLayout = "2006-01-02T15:04:05.999999"
func NowStr() string {
return time.Now().UTC().Format(PyTimeLayout)
}
func TimeStr(t time.Time) string {
return t.UTC().Format(PyTimeLayout)
}
func ParseTime(s string) time.Time {
if s == "" {
return time.Now().UTC()
}
for _, layout := range []string{PyTimeLayout, "2006-01-02T15:04:05", "2006-01-02 15:04:05", time.RFC3339} {
if t, err := time.Parse(layout, s); err == nil {
return t
}
}
return time.Now().UTC()
}