CEL input: How to subtract 1day from now()

hi,
I'm trying to pull data from an api end-point. but it requires a dynamic value to supplied (For instance Date. I want to provide yesterday's date)
In the actual go library, there are quite ways
eg Go Playground - The Go Programming Language

fmt.Println("time-24h", time.Now().Add(-24*time.Hour))

But in CEL input, how to

  • define a value? (eg in mito library this way but not working in CEL input)
  • How to put dynamic value like go to subtract 1day or 24hrs etc?
- type: cel
  interval: 10m
  resource:
    url: https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400
  program: |
    bytes(request("GET", state.url + "&date=" + now.format("2006-01-01") )
      .with({"Header": {"Accept": ["application/json"]}})
      .do_request().Body
    ).as(body,{ 
                  "events" : [{"mydata": body.decode_json() }]
              }
        )

the above example gives for 'current' date. But how to get it now(-1d) ?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.