MCPcopy Create free account
hub / github.com/brimdata/super / Call

Method Call

runtime/sam/expr/function/time.go:20–47  ·  view source on GitHub ↗
(args []super.Value)

Source from the content-addressed store, hash-verified

18}
19
20func (b *Bucket) Call(args []super.Value) super.Value {
21 args = underAll(args)
22 tsArg := args[0]
23 binArg := args[1]
24 if tsArg.IsNull() || binArg.IsNull() {
25 return super.Null
26 }
27 tsArgID := tsArg.Type().ID()
28 if tsArgID != super.IDDuration && tsArgID != super.IDTime {
29 return b.sctx.WrapError(b.name+": first argument is not a time or duration", tsArg)
30 }
31 if binArg.Type().ID() != super.IDDuration {
32 return b.sctx.WrapError(b.name+": second argument is not a duration", binArg)
33 }
34 bin := nano.Duration(binArg.Int())
35 if tsArgID == super.IDDuration {
36 dur := nano.Duration(tsArg.Int())
37 if bin != 0 {
38 dur = dur.Trunc(bin)
39 }
40 return super.NewDuration(dur)
41 }
42 ts := nano.Ts(tsArg.Int())
43 if bin != 0 {
44 ts = ts.Trunc(bin)
45 }
46 return super.NewTime(ts)
47}
48
49type Strftime struct {
50 sctx *super.Context

Callers

nothing calls this directly

Calls 11

DurationTypeAlias · 0.92
NewDurationFunction · 0.92
TsTypeAlias · 0.92
NewTimeFunction · 0.92
IsNullMethod · 0.80
WrapErrorMethod · 0.80
underAllFunction · 0.70
IDMethod · 0.65
TypeMethod · 0.65
IntMethod · 0.45
TruncMethod · 0.45

Tested by

no test coverage detected