// addUTCDate adds an UTC date value to the buffer.
490632
func (b *Builder) addUTCDate(v int64) {
	x := toUInt64(v)
	dst := b.buf.Grow(9)
	dst[0] = 0x1c
	setLength(dst[1:], ValueLength(x), 8)
}
359878
func (s *OptionStatus) SetUpdateDate(v time.Time) *OptionStatus {
	s.UpdateDate = &v
	return s
}
1289508
func ParseDate(str string) (dd Date, err error) {
	str = strings.TrimSpace(str)
	if str == "0000-00-00" {
		return
	}
	var (
		y, m, d int
	)
	if len(str) != 10 || str[4] != '-' || str[7] != '-' {
		goto invalid
	}
	if y, err = strconv.Atoi(str[0:4]); err != nil {
		return
	}
	if m, err = strconv.Atoi(str[5:7]); err != nil {
		return
	}
	if m < 0 || m > 12 { // MySQL permits month == 0
		goto invalid
	}
	if d, err = strconv.Atoi(str[8:10]); err != nil {
		return
	}
	if d < 0 { // MySQL permits day == 0
		goto invalid
	}
	switch m {
	case 1, 3, 5, 7, 8, 10, 12:
		if d > 31 {
			goto invalid
		}
	case 4, 6, 9, 11:
		if d > 30 {
			goto invalid
		}
	case 2:
		if d > 29 {
			goto invalid
		}
	}
	dd.Year = int16(y)
	dd.Month = byte(m)
	dd.Day = byte(d)
	return

invalid:
	err = errors.New("Invalid MySQL DATE string: " + str)
	return
}
965977
func (s *Store) CreateDate() int64 {
	s.mtx.RLock()
	defer s.mtx.RUnlock()

	return s.createDate
}
260122
func (s *AccessKeyLastUsed) SetLastUsedDate(v time.Time) *AccessKeyLastUsed {
	s.LastUsedDate = &v
	return s
}
937079
func (c PGPClient) PGPUpdate(ctx context.Context, __arg PGPUpdateArg) (err error) {
	err = c.Cli.Call(ctx, "keybase.1.pgp.pgpUpdate", []interface{}{__arg}, nil)
	return
}
279403
func (s *PlacementDescription) SetUpdatedDate(v time.Time) *PlacementDescription {
	s.UpdatedDate = &v
	return s
}
732835
func PutTimeToBytesUTC(b []byte, t time.Time) {
	t = t.UTC()
	binary.BigEndian.PutUint16(b[:2], uint16(t.Year()+yearShift))
	putUint48(b[2:9], uint64(t.Sub(time.Date(t.Year(), 1, 1, 0, 0, 0, 0, time.UTC))))
}
298306
func (s *ManagedPolicyDetail) SetUpdateDate(v time.Time) *ManagedPolicyDetail {
	s.UpdateDate = &v
	return s
}
962407
func (s *Member) SetUpdatedAt(v string) *Member {
	s.UpdatedAt = &v
	return s
}
472996
func (s *GetDomainDetailOutput) SetUpdatedDate(v time.Time) *GetDomainDetailOutput {
	s.UpdatedDate = &v
	return s
}
563482
func (b *BinaryConvertFilter) AddAttribute(a base.Attribute) error {
	b.attrs = append(b.attrs, a)
	return nil
}
25970
func ParseDate(dateStr string) *Date {
	dt := &Date{}

	dateStr = strings.TrimSpace(dateStr)
	dtRegex := regexp.MustCompile("([0-9]{4})(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):([0-5][0-9])(:([0-5][0-9])(\\.([0-9]+))?)?((Z)|(\\+|-)((0[0-9]|1[0-3]):([0-5][0-9])|(14):(00)))?)?)?)?")
	if m := dtRegex.FindStringSubmatch(dateStr); m != nil {
		y, mo, d, h, mi, s, ms, tzZu, tzOp, tzh, tzm := m[1], m[3], m[5], m[7], m[8], m[10], m[12], m[14], m[15], m[17], m[18]

		switch {
		case ms != "":
			dt.Precision = Millisecond

			// Fix milliseconds (.9 -> .900, .99 -> .990, .999999 -> .999 )
			switch len(ms) {
			case 1:
				ms += "00"
			case 2:
				ms += "0"
			case 3:
				// do nothing
			default:
				ms = ms[:3]
			}
		case s != "":
			dt.Precision = Second
		case mi != "":
			dt.Precision = Minute
		// NOTE: Skip hour precision since FHIR specification disallows it
		case d != "":
			dt.Precision = Day
		case mo != "":
			dt.Precision = Month
		case y != "":
			dt.Precision = Year
		default:
			dt.Precision = Millisecond
		}

		// Get the location (if no time components or no location, use local)
		loc := time.Local
		if h != "" {
			if tzZu == "Z" {
				loc, _ = time.LoadLocation("UTC")
			} else if tzOp != "" && tzh != "" && tzm != "" {
				tzhi, _ := strconv.Atoi(tzh)
				tzmi, _ := strconv.Atoi(tzm)
				offset := tzhi*60*60 + tzmi*60
				if tzOp == "-" {
					offset *= -1
				}
				loc = time.FixedZone(tzOp+tzh+tzm, offset)
			}
		}

		// Convert to a time.Time
		yInt, _ := strconv.Atoi(y)
		moInt, err := strconv.Atoi(mo)
		if err != nil {
			moInt = 1
		}
		dInt, err := strconv.Atoi(d)
		if err != nil {
			dInt = 1
		}
		hInt, _ := strconv.Atoi(h)
		miInt, _ := strconv.Atoi(mi)
		sInt, _ := strconv.Atoi(s)
		msInt, _ := strconv.Atoi(ms)

		dt.Value = time.Date(yInt, time.Month(moInt), dInt, hInt, miInt, sInt, msInt*1000*1000, loc)
	} else {
		// TODO: What should we do if the time format is wrong?  Right now, we default to NOW
		dt.Precision = Millisecond
		dt.Value = time.Now()
	}

	return dt
}
1318245
func addToSet(set string, value string) string {
	if set == "" {
		return value
	}
	return fmt.Sprintf("%s,%s", set, value)
}
1278795
func (t *Time) StrToDate(sc *stmtctx.StatementContext, date, format string) bool {
	ctx := make(map[string]int)
	var tm MysqlTime
	if !strToDate(&tm, date, format, ctx) {
		t.Time = ZeroTime
		t.Type = mysql.TypeDatetime
		t.Fsp = 0
		return false
	}
	if err := mysqlTimeFix(&tm, ctx); err != nil {
		return false
	}

	t.Time = tm
	t.Type = mysql.TypeDatetime
	return t.check(sc) == nil
}
948969
func (sao *setAttrOp) AddSelfUpdate(ptr data.BlockPointer) {
	sao.AddUpdate(ptr, ptr)
}
536040
func (date Date) AddDate(years, months, days int) Date {
	return Date{Time: date.Time.AddDate(years, months, days)}
}