diff --git a/cmd/hook/main.go b/cmd/hook/main.go index a5af35e..5d01d7b 100644 --- a/cmd/hook/main.go +++ b/cmd/hook/main.go @@ -81,6 +81,10 @@ Def( c.SetStatus(statuses.OK) }), //), +).Def( + "auth", + bond.Func(func(c *bond.Context){ + }) )) func main() { diff --git a/jsons/main.go b/jsons/main.go index 54f795c..b805e30 100644 --- a/jsons/main.go +++ b/jsons/main.go @@ -3,10 +3,10 @@ package jsons import ( "strconv" "encoding/json" + //"errors" + "time" ) - - // The package implements basic types // to be used in structures that can be parsed // from the poorly structured JSON. (Like ones that make IDs strings) @@ -86,3 +86,17 @@ func (jam *ArrayMap[V]) UnmarshalJSON(bts []byte) error { return nil } + +type Timestamp int64 +func (ts *Timestamp) UnmarshalJSON(bts []byte) error { + i, err := parseInt(string(bts), 64) + if err != nil { + return err + } + *ts = Timestamp(i) + return nil +} + +func (ts Timestamp) Time() time.Time { + return time.Unix(int64(ts), 0) +} diff --git a/jsons/timestamp_test.go b/jsons/timestamp_test.go new file mode 100644 index 0000000..a2151ba --- /dev/null +++ b/jsons/timestamp_test.go @@ -0,0 +1,14 @@ +package jsons + +//import "time" +import "testing" + +func TestTimestampJson(t *testing.T) { + //wantStr := "Thu Jan 18 2024 17:33:01 GMT+0300" + gotStr := "1705588381" + got := Timestamp(0) + err := got.UnmarshalJSON([]byte(gotStr)) + if err != nil { + t.Errorf("JSON unmarshalling error: %s", err) + } +}