func (this *Eval) evalDate(stmt *ast.Stmt) (*ast.Stmt, error) { format := stmt.Value.(string) t := stdtime.Now() stmt.Value = time.Format(t, format) stmt.Prop["time"] = t stmt.Prop["format"] = format return stmt, nil }
func (this *Eval) evalDuration(stmt *ast.Stmt) (*ast.Stmt, error) { format := stmt.Value.(string) d, err := stdtime.ParseDuration(format) if err != nil { return nil, fmt.Errorf("invalid duration: %s", format) } stmt.Value = d stmt.Prop["format"] = format return stmt, nil }