FormatElementCategory GetFormatElementCategoryFromType()

in sql_utils/public/functions/cast_date_time.cc [340:415]


FormatElementCategory GetFormatElementCategoryFromType(
    const FormatElementType& type) {
  switch (type) {
    case FormatElementType::kFormatElementTypeUnspecified:
      return FormatElementCategory::kFormatElementCategoryUnspecified;
    case FormatElementType::kSimpleLiteral:
    case FormatElementType::kDoubleQuotedLiteral:
    case FormatElementType::kWhitespace:
      return FormatElementCategory::kLiteral;
    case FormatElementType::kYYYY:
    case FormatElementType::kYYY:
    case FormatElementType::kYY:
    case FormatElementType::kY:
    case FormatElementType::kRRRR:
    case FormatElementType::kRR:
    case FormatElementType::kYCommaYYY:
    case FormatElementType::kIYYY:
    case FormatElementType::kIYY:
    case FormatElementType::kIY:
    case FormatElementType::kI:
    case FormatElementType::kSYYYY:
    case FormatElementType::kYEAR:
    case FormatElementType::kSYEAR:
      return FormatElementCategory::kYear;
    case FormatElementType::kMM:
    case FormatElementType::kMON:
    case FormatElementType::kMONTH:
    case FormatElementType::kRM:
      return FormatElementCategory::kMonth;
    case FormatElementType::kDDD:
    case FormatElementType::kDD:
    case FormatElementType::kD:
    case FormatElementType::kDAY:
    case FormatElementType::kDY:
    case FormatElementType::kJ:
      return FormatElementCategory::kDay;
    case FormatElementType::kHH:
    case FormatElementType::kHH12:
    case FormatElementType::kHH24:
      return FormatElementCategory::kHour;
    case FormatElementType::kMI:
      return FormatElementCategory::kMinute;
    case FormatElementType::kSS:
    case FormatElementType::kSSSSS:
    case FormatElementType::kFFN:
      return FormatElementCategory::kSecond;
    case FormatElementType::kAM:
    case FormatElementType::kPM:
    case FormatElementType::kAMWithDots:
    case FormatElementType::kPMWithDots:
      return FormatElementCategory::kMeridianIndicator;
    case FormatElementType::kTZH:
    case FormatElementType::kTZM:
      return FormatElementCategory::kTimeZone;
    case FormatElementType::kCC:
    case FormatElementType::kSCC:
      return FormatElementCategory::kCentury;
    case FormatElementType::kQ:
      return FormatElementCategory::kQuarter;
    case FormatElementType::kIW:
    case FormatElementType::kWW:
    case FormatElementType::kW:
      return FormatElementCategory::kWeek;
    case FormatElementType::kAD:
    case FormatElementType::kBC:
    case FormatElementType::kADWithDots:
    case FormatElementType::kBCWithDots:
      return FormatElementCategory::kEraIndicator;
    case FormatElementType::kSP:
    case FormatElementType::kTH:
    case FormatElementType::kSPTH:
    case FormatElementType::kTHSP:
    case FormatElementType::kFM:
      return FormatElementCategory::kMisc;
  }
}