code: func ExtractDatetimeNum(t *Time, unit string) (int64, error) {
  	// TODO: Consider time_zone variable.
  	switch strings.ToUpper(unit) {
  	case "DAY":
  		return int64(t.Time.Day()), nil
  	case "WEEK":
  		week := t.Time.Week(0)
  		return int64(week), nil
  	case "MONTH":
  		return int64(t.Time.Month()), nil
  	case "QUARTER":
  		m := int64(t.Time.Month())
  		// 1 - 3 -> 1
  		// 4 - 6 -> 2
  		// 7 - 9 -> 3
  		// 10 - 12 -> 4
  		return (m + 2) / 3, nil
  	case "YEAR":
  		return int64(t.Time.Year()), nil
  	case "DAY_MICROSECOND":
  		h, m, s := t.Clock()
  		d := t.Time.Day()
  		return int64(d*1000000+h*10000+m*100+s)*1000000 + int64(t.Time.Microsecond()), nil
  	case "DAY_SECOND":
  		h, m, s := t.Clock()
  		d := t.Time.Day()
  		return int64(d)*1000000 + int64(h)*10000 + int64(m)*100 + int64(s), nil
  	case "DAY_MINUTE":
  		h, m, _ := t.Clock()
  		d := t.Time.Day()
  		return int64(d)*10000 + int64(h)*100 + int64(m), nil
  	case "DAY_HOUR":
  		h, _, _ := t.Clock()
  		d := t.Time.Day()
  		return int64(d)*100 + int64(h), nil
  	case "YEAR_MONTH":
  		y, m := t.Time.Year(), t.Time.Month()
  		return int64(y)*100 + int64(m), nil
  	default:
  		return 0, errors.Errorf("invalid unit %s", unit)
  	}
  }
docs: // ExtractDatetimeNum extracts time value number from datetime unit and format.