/*
 * Copyright 2010 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.gwt.i18n.client.impl.cldr;

// DO NOT EDIT - GENERATED FROM CLDR AND ICU DATA

/**
 * Implementation of DateTimeFormatInfo for the "hu" locale.
 */
public class DateTimeFormatInfoImpl_hu extends DateTimeFormatInfoImpl {

  @Override
  public String[] ampms() {
    return new String[] {
        "de.",
        "du."
    };
  }

  @Override
  public String dateFormatFull() {
    return "y. MMMM d., EEEE";
  }

  @Override
  public String dateFormatLong() {
    return "y. MMMM d.";
  }

  @Override
  public String dateFormatMedium() {
    return "yyyy.MM.dd.";
  }

  @Override
  public String dateFormatShort() {
    return "yyyy.MM.dd.";
  }

  @Override
  public String[] erasFull() {
    return new String[] {
        "időszámításunk előtt",
        "időszámításunk szerint"
    };
  }

  @Override
  public String[] erasShort() {
    return new String[] {
        "i. e.",
        "i. sz."
    };
  }

  @Override
  public String formatHour24Minute() {
    return "H:mm";
  }

  @Override
  public String formatHour24MinuteSecond() {
    return "H:mm:ss";
  }

  @Override
  public String formatMonthAbbrevDay() {
    return "MMM d.";
  }

  @Override
  public String formatMonthFullDay() {
    return "MMMM d.";
  }

  @Override
  public String formatMonthNumDay() {
    return "M.d.";
  }

  @Override
  public String formatYearMonthAbbrev() {
    return "y. MMM";
  }

  @Override
  public String formatYearMonthAbbrevDay() {
    return "y. MMM d.";
  }

  @Override
  public String formatYearMonthFull() {
    return "y. MMMM";
  }

  @Override
  public String formatYearMonthFullDay() {
    return "y. MMMM d.";
  }

  @Override
  public String formatYearMonthNum() {
    return "y.M";
  }

  @Override
  public String formatYearMonthNumDay() {
    return "y.M.d.";
  }

  @Override
  public String formatYearMonthWeekdayDay() {
    return "y. MMM d., EEE";
  }

  @Override
  public String formatYearQuarterFull() {
    return "y/QQQQ";
  }

  @Override
  public String formatYearQuarterShort() {
    return "y/Q";
  }

  @Override
  public String[] monthsFull() {
    return new String[] {
        "január",
        "február",
        "március",
        "április",
        "május",
        "június",
        "július",
        "augusztus",
        "szeptember",
        "október",
        "november",
        "december"
    };
  }

  @Override
  public String[] monthsNarrow() {
    return new String[] {
        "J",
        "F",
        "M",
        "Á",
        "M",
        "J",
        "J",
        "A",
        "Sz",
        "O",
        "N",
        "D"
    };
  }

  @Override
  public String[] monthsShort() {
    return new String[] {
        "jan.",
        "febr.",
        "márc.",
        "ápr.",
        "máj.",
        "jún.",
        "júl.",
        "aug.",
        "szept.",
        "okt.",
        "nov.",
        "dec."
    };
  }

  @Override
  public String[] quartersFull() {
    return new String[] {
        "I. negyedév",
        "II. negyedév",
        "III. negyedév",
        "IV. negyedév"
    };
  }

  @Override
  public String[] quartersShort() {
    return new String[] {
        "N1",
        "N2",
        "N3",
        "N4"
    };
  }

  @Override
  public String timeFormatFull() {
    return "H:mm:ss zzzz";
  }

  @Override
  public String timeFormatLong() {
    return "H:mm:ss z";
  }

  @Override
  public String timeFormatMedium() {
    return "H:mm:ss";
  }

  @Override
  public String timeFormatShort() {
    return "H:mm";
  }

  @Override
  public String[] weekdaysFull() {
    return new String[] {
        "vasárnap",
        "hétfő",
        "kedd",
        "szerda",
        "csütörtök",
        "péntek",
        "szombat"
    };
  }

  @Override
  public String[] weekdaysNarrow() {
    return new String[] {
        "V",
        "H",
        "K",
        "Sz",
        "Cs",
        "P",
        "Sz"
    };
  }

  @Override
  public String[] weekdaysShort() {
    return new String[] {
        "V",
        "H",
        "K",
        "Sze",
        "Cs",
        "P",
        "Szo"
    };
  }
}
