WIP: Export Kontor DB
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s

This commit is contained in:
Thomas Peetz
2026-10-01 17:40:17 +02:00
parent f5abb44466
commit 4aaf580735
47 changed files with 1101 additions and 369 deletions
+62
View File
@@ -0,0 +1,62 @@
package helpers
import (
"encoding/json"
"time"
)
type DateOnly struct {
time.Time
}
func (d DateOnly) MarshalJSON() ([]byte, error) {
if d.IsZero() {
return []byte("null"), nil
}
return json.Marshal(d.Format("2006-01-02"))
}
func (d *DateOnly) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
if s == "" {
return nil
}
t, err := time.Parse("2006-01-02", s)
if err != nil {
return err
}
d.Time = t
return nil
}
type KontorTime struct {
time.Time
}
const layout = "2006-01-02 15:04:05.000000"
func (kt KontorTime) MarshalJSON() ([]byte, error) {
if kt.IsZero() {
return []byte("null"), nil
}
return json.Marshal(kt.Format(layout))
}
func (kt *KontorTime) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
if s == "" {
return nil
}
t, err := time.Parse(layout, s)
if err != nil {
return err
}
kt.Time = t
return nil
}