2024-10-09 19:57:52 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
2024-10-12 00:09:25 +03:00
|
|
|
type ClockFun struct{}
|
|
|
|
|
|
|
|
func (cf *ClockFun) call(i *Interpreter, args ...any) any {
|
|
|
|
return time.Now().Unix()
|
|
|
|
}
|
2024-10-09 19:57:52 +03:00
|
|
|
|
2024-10-12 00:09:25 +03:00
|
|
|
func (cf *ClockFun) arity() int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func defineGlobals(env *Environment) {
|
|
|
|
env.define("clock", &ClockFun{})
|
2024-10-09 19:57:52 +03:00
|
|
|
}
|