All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.squarespace.cldrengine.api.BuddhistDate Maven / Gradle / Ivy

package com.squarespace.cldrengine.api;

/**
 * A date in the Buddhist calendar.
 *
 * type: buddhist
 */
public class BuddhistDate extends GregorianDate {

  protected BuddhistDate(int firstDay, int minDays) {
    super(CalendarType.BUDDHIST, firstDay, minDays);
  }

  @Override
  public BuddhistDate add(TimePeriod fields) {
    Pair result = this._add(fields);
    return new BuddhistDate(this.firstDay, this.minDays)
        ._initFromJD(result._1, Math.round(result._2), this.timeZoneId());
  }

  @Override
  public String toString() {
    return this._toString("Buddhist");
  }

  public static BuddhistDate fromUnixEpoch(long epoch, String zoneId, int firstDay, int minDays) {
    return new BuddhistDate(firstDay, minDays)._initFromUnixEpoch(epoch, zoneId);
  }

  protected BuddhistDate _initFromUnixEpoch(long epoch, String zoneId) {
    super.initFromUnixEpoch(epoch, zoneId);
    this.initFields(this.fields);
    return this;
  }

  protected BuddhistDate _initFromJD(long jd, long msDay, String zoneId) {
    super.initFromJD(jd, msDay, zoneId);
    this.initFields(this.fields);
    return this;
  }

  protected void initFields(long[] f) {
    super.initFields(f);
    computeBuddhistFields(f);
  }

  private void computeBuddhistFields(long[] f) {
    f[DateField.ERA] = 0;
    f[DateField.YEAR] = f[DateField.EXTENDED_YEAR] - CalendarConstants.BUDDHIST_ERA_START;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy