/*
 * Copyright 2012 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.shared.impl.cldr;
// DO NOT EDIT - GENERATED FROM CLDR AND ICU DATA

/**
 * Implementation of DateTimeFormatInfo for the "sd" locale.
 */
public class DateTimeFormatInfoImpl_sd extends DateTimeFormatInfoImpl {

  @Override
  public String[] ampms() {
    return new String[] {
        "صبح، منجهند",
        "شام، منجهند"
    };
  }

  @Override
  public String[] erasFull() {
    return new String[] {
        "مسيح کان اڳ",
        "عيسوي کان پهرين"
    };
  }

  @Override
  public String[] erasShort() {
    return new String[] {
        "BC",
        "CD"
    };
  }

  @Override
  public int firstDayOfTheWeek() {
    return 0;
  }

  @Override
  public String formatYearMonthNumDay() {
    return "y-MM-dd";
  }

  @Override
  public String[] monthsFull() {
    return new String[] {
        "جنوري",
        "فيبروري",
        "مارچ",
        "اپريل",
        "مئي",
        "جون",
        "جولاءِ",
        "آگسٽ",
        "سيپٽمبر",
        "آڪٽوبر",
        "نومبر",
        "ڊسمبر"
    };
  }

  @Override
  public String[] monthsShort() {
    return new String[] {
        "جنوري",
        "فيبروري",
        "مارچ",
        "اپريل",
        "مئي",
        "جون",
        "جولاءِ",
        "آگسٽ",
        "سيپٽمبر",
        "آڪٽوبر",
        "نومبر",
        "ڊسمبر"
    };
  }

  @Override
  public String[] quartersFull() {
    return new String[] {
        "پهرين ٽي ماهي",
        "ٻين ٽي ماهي",
        "ٽين ٽي ماهي",
        "چوٿين ٽي ماهي"
    };
  }

  @Override
  public String[] quartersShort() {
    return new String[] {
        "Q1",
        "Q2",
        "Q3",
        "Q5"
    };
  }

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

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

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

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

  @Override
  public String[] weekdaysFull() {
    return new String[] {
        "آچر",
        "سومر",
        "اڱارو",
        "اربع",
        "خميس",
        "جمعو",
        "ڇنڇر"
    };
  }

  @Override
  public String[] weekdaysNarrow() {
    return new String[] {
        "آچر",
        "سو",
        "اڱارو",
        "اربع",
        "خم",
        "جمعو",
        "ڇنڇر"
    };
  }

  @Override
  public String[] weekdaysShort() {
    return new String[] {
        "آچر",
        "سومر",
        "اڱارو",
        "اربع",
        "خميس",
        "جمعو",
        "ڇنڇر"
    };
  }
}
