// UnmarshalDateTime unmarshals time.Time from the SOAP "dateTime" type. This
// returns a value in the local timezone.
772088
func UnmarshalDateTime(s string) (result time.Time, err error) {
	dateStr, timeStr, zoneStr, err := splitCompleteDateTimeZone(s)
	if err != nil {
		return
	}

	if len(zoneStr) != 0 {
		err = fmt.Errorf("soap datetime: unexpected timezone in %q", s)
		return
	}

	year, month, day, err := parseDateParts(dateStr)
	if err != nil {
		return
	}

	var hour, minute, second int
	if len(timeStr) != 0 {
		hour, minute, second, err = parseTimeParts(timeStr)
		if err != nil {
			return
		}
	}

	result = time.Date(year, time.Month(month), day, hour, minute, second, 0, localLoc)
	return
}
444507
func (d *Day) UnmarshalJSON(b []byte) error {
	s := string(b)

	i, err := strconv.ParseInt(s, 10, 0)

	if err != nil {
		if s != `"Last"` {
			return fmt.Errorf("day cannot unmarshal %s", b)
		}

		*d = Day(Last)
	} else {
		if i < 1 || i > 31 {
			return fmt.Errorf("day must be 1-31. Was %#v", i)
		}

		*d = Day(i)
	}

	return nil
}
673715
func (t *AWSEpochTime) UnmarshalJSON(data []byte) error {
	var epochTime struct {
		Sec int64 `json:"AWS:EpochTime"`
	}
	err := json.Unmarshal(data, &epochTime)
	if err != nil {
		return err
	}
	t.Time = time.Unix(epochTime.Sec, 0).UTC()
	return nil
}
360076
func (t *JSONTime) UnmarshalJSON(data []byte) error {
	ts, err := strconv.ParseInt(string(data), 10, 64)
	if err != nil {
		return err
	}
	*t = JSONTime(time.Unix(0, ts*1000))
	return nil
}
1162640
func ParseTime(format string, t string) (d time.Time, err error) {
	return time.Parse(format, strings.ToUpper(t))
}
794731
func (t *UnixTime) UnmarshalText(raw []byte) error {
	var unmarshaled time.Time

	if err := unmarshaled.UnmarshalText(raw); err != nil {
		return err
	}

	*t = UnixTime(unmarshaled)
	return nil
}
414793
func (t *Timestamp) UnmarshalJSON(data []byte) error {
	strValue := string(data)
	strValue = strings.Replace(strValue, `"`, ``, -1)
	if strings.Contains(strValue, ".") {
		components := strings.Split(strValue, ".")
		if integerValue, integerErr := strconv.ParseInt(components[0], 10, 64); integerErr == nil {
			t.time = time.Unix(integerValue, 0)
			t.uuid = components[1]
		}
	}

	if integerValue, integerErr := strconv.ParseInt(strValue, 10, 64); integerErr == nil {
		t.time = time.Unix(integerValue, 0)
	}

	return nil
}
376079
func StrToDateTime(sc *stmtctx.StatementContext, str string, fsp int) (Time, error) {
	return ParseTime(sc, str, mysql.TypeDatetime, fsp)
}
889323
func (t *Time) UnmarshalJSON(value []byte) (err error) {
	v := strings.Trim(string(value), "\"")

	if v == "" {
		t.Time = time.Time{}

		return
	}

	timestamp, err := strconv.ParseInt(v, 10, 64)

	if err != nil {
		return
	}

	t.Time = time.Unix(timestamp, 0)

	return
}
1168146
func (d *Date) UnmarshalJSON(b []byte) error {
	t, err := time.Parse(`"2006-01-02"`, string(b))

	if err != nil {
		return err
	}

	*d = Date(t)
	return nil
}
772121
func (m *Month) UnmarshalJSON(b []byte) error {
	switch string(b) {
	case `1`, `"January"`:
		*m = January
	case `2`, `"February"`:
		*m = February
	case `3`, `"March"`:
		*m = March
	case `4`, `"April"`:
		*m = April
	case `5`, `"May"`:
		*m = May
	case `6`, `"June"`:
		*m = June
	case `7`, `"July"`:
		*m = July
	case `8`, `"August"`:
		*m = August
	case `9`, `"September"`:
		*m = September
	case `10`, `"October"`:
		*m = October
	case `11`, `"November"`:
		*m = November
	case `12`, `"December"`:
		*m = December
	default:
		return fmt.Errorf("Weekday cannot unmarshal %s", b)
	}

	return nil
}
1370880
func (t *TimeRFC1123) UnmarshalJSON(data []byte) (err error) {
	t.Time, err = ParseTime(rfc1123JSON, string(data))
	if err != nil {
		return err
	}
	return nil
}
617055
func (m *Time) Unmarshal(data []byte) error {
	p := ProtoTime{}
	if err := p.Unmarshal(data); err != nil {
		return err
	}
	m.Time = time.Unix(p.Timestamp.Seconds, int64(p.Timestamp.Nanos))
	return nil
}
410404
func ParseTime(rfc3339Time string) int {
	t, _ := time.Parse(
		time.RFC3339,
		rfc3339Time)

	return TimeToEpoch(t)
}
583177
func (t *Timestamp) UnmarshalText(text []byte) (err error) {
	var i int
	if i, err = strconv.Atoi(string(bytes.Trim(text, "\""))); err != nil {
		return
	}
	t.Time = time.Unix(int64(i), 0)
	return
}
421869
func (do *DateOnly) UnmarshalJSON(b []byte) error {
	ts, err := time.Parse(dateOnlyFmtTicked, string(b))
	if err != nil {
		return err
	}

	*do = DateOnly(ts)
	return nil
}
1135748
func ParseTime(layout string, timeStr string) time.Time {
	res, err := time.Parse(layout, timeStr)
	if err != nil {
		panic(err)
	}
	return res
}