func (t *Timestamp) SetBSON(raw bson.Raw) error {
	var tm time.Time
	if err := raw.Unmarshal(&tm); err != nil {
		return err
	}
	t.Time = tm
	return nil
}
SetBSON implements the bson Setter interface
package timestamp
import (
	"database/sql/driver"
	"fmt"
	"strings"
	"time"
	"github.com/araddon/dateparse"
	"github.com/globalsign/mgo/bson"
)
const TimestampFormatLayout = "2006-01-02 15:04:05"
func New() Timestamp {
	return Timestamp{}
}
func NewWithTime(t time.Time) Timestamp {
	return Timestamp{Time: t}
}
func Now() Timestamp {
	return Timestamp{Time: time.Now()}
}
func Unix(sec int64, nsec int64) Timestamp {
	return Timestamp{time.Unix(sec, nsec)}
}
func Date(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) Timestamp {
	return Timestamp{time.Date(year, month, day, hour, min, sec, nsec, loc)}
}
func AutoSet(data interface{}, fields ...string) {
	if m, ok := data.(map[string]interface{}); ok {
		for _, field := range fields {
			v, exists := m[field]
			if !exists {
				continue
			}
			if t, ok := v.(float64); ok {
				m[field] = Unix(int64(t), 0)
			}
			if t, ok := v.(int64); ok {
				m[field] = Unix(t, 0)
			}
		}
	}
}
type Timestamp struct {
	time.Time
}
func (t Timestamp) Pointer() *Timestamp {
	return &t
}
func (t Timestamp) MarshalJSON() ([]byte, error) {
	if t.IsZero() || t.Time.UnixNano() == time.Unix(0, 0).UnixNano() {
		return []byte("null"), nil
	}
	ts := t.Unix()
	stamp := fmt.Sprint(ts)
	return []byte(stamp), nil
}
func (t *Timestamp) UnmarshalJSON(b []byte) error {
	var (
		err error
		str = strings.Replace(string(b), "\"", "", -1)
	)
	if str == "null" || str == "0" {
		return nil
	}
	t.Time, err = dateparse.ParseAny(str)
	return err
}
func (t Timestamp) GetBSON() (interface{}, error) {
	if t.IsZero() || t.Time.UnixNano() == time.Unix(0, 0).UnixNano() {
		return nil, nil
	}
	return t, nil
}