func (t *TimestampType) Set(value interface{}) {
	if value != nil {
		switch v := value.(type) {
		case time.Time:
			t.valid, t.val = true, v
		default:
			sTime := util.ToString(v)
			if sTime != util.BLANK && sTime != "null" {
				sTime = strings.Replace(sTime, "T", " ", -1)
				if len(sTime) > 26 {
					sTime = sTime[0:26]
				}
				sTime = strings.TrimSpace(sTime)
				parseTime, err := time.Parse("2006-01-02 15:04:05.999999", sTime)
				if err != nil {
					log.Errorf("Time parse error: %v", err)
					break
				}
				t.valid, t.val = true, parseTime.Local()
			}
		}
	}
	if !t.valid {
		t.val = emptyTime
	}
}
func (t *StringType) Set(value interface{}) {
	if value != nil {
		t.valid, t.val = true, util.ToString(value)
	} else {
		t.valid, t.val = false, util.BLANK
	}
}
Beispiel #3
0
func (e *Env) String() string {
	if e.hasValue() {
		return e.val
	}
	return util.ToString(e.defVal)
}
func (t IntType) Value() (driver.Value, error) {
	if !t.valid {
		return nil, nil
	}
	return util.ToString(t.val), nil
}