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

Method Call

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

Source from the content-addressed store, hash-verified

52}
53
54func (s *Strftime) Call(args []super.Value) super.Value {
55 formatArg, timeArg := args[0], args[1]
56 if formatArg.IsNull() || timeArg.IsNull() {
57 return super.Null
58 }
59 if !formatArg.IsString() {
60 return s.sctx.WrapError("strftime: string value required for format arg", formatArg)
61 }
62 if super.TypeUnder(timeArg.Type()) != super.TypeTime {
63 return s.sctx.WrapError("strftime: time value required for time arg", args[1])
64 }
65 format := formatArg.AsString()
66 if s.formatter == nil || s.formatter.Pattern() != format {
67 var err error
68 if s.formatter, err = strftime.New(format); err != nil {
69 return s.sctx.WrapError("strftime: "+err.Error(), formatArg)
70 }
71 }
72 out := s.formatter.FormatString(timeArg.AsTime().Time())
73 return super.NewString(out)
74}

Callers

nothing calls this directly

Calls 11

TypeUnderFunction · 0.92
NewStringFunction · 0.92
IsNullMethod · 0.80
IsStringMethod · 0.80
WrapErrorMethod · 0.80
AsStringMethod · 0.80
NewMethod · 0.80
AsTimeMethod · 0.80
TypeMethod · 0.65
ErrorMethod · 0.45
TimeMethod · 0.45

Tested by

no test coverage detected