(vm *goja.Runtime)
| 248 | } |
| 249 | |
| 250 | func AddTimeRange(vm *goja.Runtime) error { |
| 251 | return vm.GlobalObject().Set("timeRange", func(call goja.FunctionCall) goja.Value { |
| 252 | args := call.Arguments |
| 253 | if len(args) == 0 { |
| 254 | return vm.ToValue(false) |
| 255 | } |
| 256 | gmt := false |
| 257 | if strings.ToUpper(args[len(args)-1].String()) == "GMT" { |
| 258 | gmt = true |
| 259 | args = args[:len(args)-1] |
| 260 | } |
| 261 | return vm.ToValue( |
| 262 | timeRange( |
| 263 | gmt, |
| 264 | mapSlice(args, func(v goja.Value) int { return int(v.ToInteger()) })..., |
| 265 | ), |
| 266 | ) |
| 267 | }) |
| 268 | } |