示例#1
0
文件: eval.go 项目: yonglehou/hpipe
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
}
示例#2
0
文件: eval.go 项目: yonglehou/hpipe
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
}