func NewTemporal(id string, t time.Time) (*Predicate, error) {
	if id == "" {
		return nil, fmt.Errorf("predicate.NewTemporal(%q, %v) cannot create a temporal predicate with empty ID", id, t)
	}
	return &Predicate{
		id:     ID(id),
		anchor: &t,
	}, nil
}
NewTemporal creates a new temporal predicate.
package predicate
import (
	"bytes"
	"encoding/binary"
	"fmt"
	"strconv"
	"strings"
	"time"
	"github.com/pborman/uuid"
)
type Type uint8
const (
	Immutable Type = iota
	Temporal
)
func (t Type) String() string {
	switch t {
	case Immutable:
		return "IMMUTABLE"
	case Temporal:
		return "TEMPORAL"
	default:
		return "UNKNOWN"
	}
}
type ID string
func (i *ID) String() string {
	return string(*i)
}
type Predicate struct {
	id     ID
	anchor *time.Time
}
func (p *Predicate) String() string {
	if p.anchor == nil {
		return fmt.Sprintf("%q@[]", p.id)
	}
	return fmt.Sprintf("%q@[%s]", p.id, p.anchor.Format(time.RFC3339Nano))
}
func Parse(s string) (*Predicate, error) {
	raw := strings.TrimSpace(s)
	if raw == "" {
		return nil, fmt.Errorf("predicate.Parse cannot create predicate from empty string %q", s)
	}
	if raw[0] != '"' {
		return nil, fmt.Errorf("predicate.Parse failed to parse since string does not start with \" in %s", s)
	}
	idx := strings.Index(raw, "\"@[")
	if idx < 0 {
		return nil, fmt.Errorf("predicate.Parse could not find anchor definition in %s", raw)
	}
	id, ta := raw[0:idx+1], raw[idx+3:len(raw)-1]
	id, err := strconv.Unquote(id)
	if err != nil {
		return nil, fmt.Errorf("predicate.Parse can't unquote id in %s: %v", raw, err)
	}
	if ta == "" {
		return &Predicate{
			id: ID(id),
		}, nil
	}
	if ta[0] == '"' {
		ta = ta[1:]
	}
	if ta[len(ta)-1] == '"' {
		ta = ta[:len(ta)-1]
	}
	pta, err := time.Parse(time.RFC3339Nano, ta)
	if err != nil {
		return nil, fmt.Errorf("predicate.Parse failed to parse time anchor %s in %s with error %v", ta, raw, err)
	}
	return &Predicate{
		id:     ID(id),
		anchor: &pta,
	}, nil
}
func (p *Predicate) ID() ID {
	return p.id
}
func (p *Predicate) Type() Type {
	if p.anchor == nil {
		return Immutable
	}
	return Temporal
}
func (p *Predicate) TimeAnchor() (*time.Time, error) {
	if p.anchor == nil {
		return nil, fmt.Errorf("predicate.TimeAnchor cannot return anchor for immutable predicate %v", p)
	}
	return p.anchor, nil
}
func NewImmutable(id string) (*Predicate, error) {
	if id == "" {
		return nil, fmt.Errorf("predicate.NewImmutable(%q) cannot create a immutable predicate with empty ID", id)
	}
	return &Predicate{
		id: ID(id),
	}, nil
}