// DateUpdatesAsTime returns FaxBase.DateUpdated as a time.Time object
// instead of a string.
485573
func (d *FaxBase) DateUpdatesAsTime() (time.Time, error) {
	return time.Parse(time.RFC1123Z, d.DateUpdated)
}
1256525
func ParseTime(timestamp string) (time.Time, error) {
	var err error
	for _, timeFmt := range ValidTimestamps {
		// Try to parse
		t, err := time.Parse(timeFmt, timestamp)
		if err == nil { // If successful, return
			return t, nil
		}
	}
	return time.Now(), err
}
434069
func (h *Hook) GetUpdatedAt() time.Time {
	if h == nil || h.UpdatedAt == nil {
		return time.Time{}
	}
	return *h.UpdatedAt
}
1140321
func parseTime(t interface{}) (time.Time, error) {
	var err error
	var calcTime time.Time
	switch v := t.(type) {
	case string:
		if calcTime, err = time.Parse(TimeFormat, v); err != nil {
			return time.Time{}, errors.New("cannot parse string time")
		}
	case int64:
		calcTime = time.Unix(v, 0).UTC()
	default:
		return time.Time{}, errors.New("arg must be a timestamp")
	}
	return calcTime, nil
}
333733
func (p *PushEventRepository) GetUpdatedAt() Timestamp {
	if p == nil || p.UpdatedAt == nil {
		return Timestamp{}
	}
	return *p.UpdatedAt
}
661637
func (tr *Repo) UpdateTimestamp(s *data.Signed) error {
	jsonData, err := json.Marshal(s)
	if err != nil {
		return err
	}
	meta, err := data.NewFileMeta(bytes.NewReader(jsonData), data.NotaryDefaultHashes...)
	if err != nil {
		return err
	}
	tr.Timestamp.Signed.Meta[data.CanonicalSnapshotRole.String()] = meta
	tr.Timestamp.Dirty = true
	return nil
}
1002020
func GetUptime(query map[string]string, lastModifiedSince string) (*Uptime, string, error) {
	uptime := new(Uptime)

	if lastModified, err := executeRequest("uptime", query, lastModifiedSince, &uptime); err != nil {
		return nil, "", err
	} else {
		return uptime, lastModified, nil
	}
}
1021633
func (s *EnvironmentDescription) SetDateUpdated(v time.Time) *EnvironmentDescription {
	s.DateUpdated = &v
	return s
}
853902
func (b *builtinLastDaySig) evalTime(row chunk.Row) (types.Time, bool, error) {
	arg, isNull, err := b.args[0].EvalTime(b.ctx, row)
	if isNull || err != nil {
		return types.Time{}, true, handleInvalidTimeError(b.ctx, err)
	}
	tm := arg.Time
	var day int
	year, month := tm.Year(), tm.Month()
	if month == 0 {
		return types.Time{}, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String()))
	}
	day = types.GetLastDay(year, month)
	ret := types.Time{
		Time: types.FromDate(year, month, day, 0, 0, 0, 0),
		Type: mysql.TypeDate,
		Fsp:  types.DefaultFsp,
	}
	return ret, false, nil
}
791907
func (p *ProjectColumn) GetUpdatedAt() Timestamp {
	if p == nil || p.UpdatedAt == nil {
		return Timestamp{}
	}
	return *p.UpdatedAt
}
1183289
func ThreadsUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
	var input ThreadsUpdateRequest
	err := utils.ParseRequest(r, &input)
	if err != nil {
		env.Log.WithFields(logrus.Fields{
			"error": err.Error(),
		}).Warn("Unable to decode a request")

		utils.JSONResponse(w, 400, &ThreadsUpdateResponse{
			Success: false,
			Message: "Invalid input format",
		})
		return
	}

	// Get the thread from the database
	thread, err := env.Threads.GetThread(c.URLParams["id"])
	if err != nil {
		utils.JSONResponse(w, 404, &ThreadsUpdateResponse{
			Success: false,
			Message: "Thread not found",
		})
		return
	}

	// Fetch the current session from the middleware
	session := c.Env["token"].(*models.Token)

	// Check for ownership
	if thread.Owner != session.Owner {
		utils.JSONResponse(w, 404, &ContactsUpdateResponse{
			Success: false,
			Message: "Contact not found",
		})
		return
	}

	if input.Labels != nil && !reflect.DeepEqual(thread.Labels, input.Labels) {
		thread.Labels = input.Labels
	}

	if input.LastRead != nil && *input.LastRead != thread.LastRead {
		thread.LastRead = *input.LastRead
	}

	if input.IsRead != nil && *input.IsRead != thread.IsRead {
		thread.IsRead = *input.IsRead
	}

	// Disabled for now, as we're using DateModified for sorting by the date of the last email
	// thread.DateModified = time.Now()

	err = env.Threads.UpdateID(c.URLParams["id"], thread)
	if err != nil {
		env.Log.WithFields(logrus.Fields{
			"error": err.Error(),
			"id":    c.URLParams["id"],
		}).Error("Unable to update a thread")

		utils.JSONResponse(w, 500, &ThreadsUpdateResponse{
			Success: false,
			Message: "Internal error (code TH/UP/01)",
		})
		return
	}

	// Write the thread to the response
	utils.JSONResponse(w, 200, &ThreadsUpdateResponse{
		Success: true,
		Thread:  thread,
	})
}
350871
func (b *builtinTimestampLiteralSig) evalTime(row chunk.Row) (types.Time, bool, error) {
	return b.tm, false, nil
}
267317
func (r *RepositoryComment) GetUpdatedAt() time.Time {
	if r == nil || r.UpdatedAt == nil {
		return time.Time{}
	}
	return *r.UpdatedAt
}
1088922
func (s *ServerRPC) ServiceUpdate(ctx context.Context, req *types.ServiceUpdateRequest) (*types.ServiceUpdateResponse, error) {
	err := s.daemon.UpdateService(req.PodID, req.Services)
	if err != nil {
		return nil, err
	}

	return &types.ServiceUpdateResponse{}, nil
}
118123
func (s *UpdateStateMachineOutput) SetUpdateDate(v time.Time) *UpdateStateMachineOutput {
	s.UpdateDate = &v
	return s
}
362515
func (b *builtinCurrentDateSig) evalTime(row chunk.Row) (d types.Time, isNull bool, err error) {
	tz := b.ctx.GetSessionVars().Location()
	var nowTs = &b.ctx.GetSessionVars().StmtCtx.NowTs
	if nowTs.Equal(time.Time{}) {
		*nowTs = time.Now()
	}
	year, month, day := nowTs.In(tz).Date()
	result := types.Time{
		Time: types.FromDate(year, int(month), day, 0, 0, 0, 0),
		Type: mysql.TypeDate,
		Fsp:  0}
	return result, false, nil
}
548837
func ParseTime(s string) (t time.Time, err error) {
	formats := []string{time.RFC3339, time.RFC3339Nano}
	for _, format := range formats {
		t, err = time.Parse(format, s)
		if err == nil {
			return
		}
	}
	return
}