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

Function stringToTime

runtime/vam/expr/cast/number.go:183–204  ·  view source on GitHub ↗
(vec *vector.String, index []uint32)

Source from the content-addressed store, hash-verified

181}
182
183func stringToTime(vec *vector.String, index []uint32) (vector.Any, []uint32) {
184 var ts []int64
185 var errs []uint32
186 for i := range lengthOf(vec, index) {
187 idx := i
188 if index != nil {
189 idx = index[i]
190 }
191 b := vec.Table().Bytes(idx)
192 if gotime, err := dateparse.ParseAny(byteconv.UnsafeString(b)); err != nil {
193 f, ferr := byteconv.ParseFloat64(b)
194 if ferr != nil {
195 errs = append(errs, i)
196 continue
197 }
198 ts = append(ts, int64(f))
199 } else {
200 ts = append(ts, gotime.UnixNano())
201 }
202 }
203 return vector.NewInt(super.TypeTime, ts), errs
204}
205
206func stringToUint(vec *vector.String, typ super.Type, index []uint32) (vector.Any, []uint32) {
207 bits := coerce.UintBits(typ)

Callers 1

castStringToNumberFunction · 0.85

Calls 6

UnsafeStringFunction · 0.92
ParseFloat64Function · 0.92
NewIntFunction · 0.92
lengthOfFunction · 0.85
BytesMethod · 0.45
TableMethod · 0.45

Tested by

no test coverage detected