code: func builtinWeek(args []types.Datum, ctx context.Context) (types.Datum, error) {
  	d, err := convertToTime(ctx.GetSessionVars().StmtCtx, args[0], mysql.TypeDate)
  	if err != nil || d.IsNull() {
  		return d, errors.Trace(err)
  	}
  
  	// No need to check type here.
  	t := d.GetMysqlTime()
  	if t.IsZero() {
  		// TODO: log warning or return error?
  		d.SetNull()
  		return d, nil
  	}
  
  	var mode int
  	if len(args) > 1 {
  		v, err := args[1].ToInt64(ctx.GetSessionVars().StmtCtx)
  		if err != nil {
  			return d, errors.Trace(err)
  		}
  		mode = int(v)
  	}
  
  	week := t.Time.Week(mode)
  	wi := int64(week)
  	d.SetInt64(wi)
  	return d, nil
  }
docs: // See http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_week