github.com/avenga/couper@v1.12.2/eval/lib/time.go (about)

     1  package lib
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/zclconf/go-cty/cty"
     7  	"github.com/zclconf/go-cty/cty/function"
     8  )
     9  
    10  var (
    11  	UnixtimeFunc = newUnixtimeFunction()
    12  )
    13  
    14  func newUnixtimeFunction() function.Function {
    15  	return function.New(&function.Spec{
    16  		Params: []function.Parameter{},
    17  		Type:   function.StaticReturnType(cty.Number),
    18  		Impl: func(args []cty.Value, _ cty.Type) (ret cty.Value, err error) {
    19  			return cty.NumberIntVal(time.Now().Unix()), nil
    20  		},
    21  	})
    22  }