// Path: itl/src/main/java/org/arabeyes/itl/hijri/HijriModule.java
// static class sDate {
//     int day;		/* Day */
//     int month;		/* Month */
//     int year;		/* Year */
//     int weekday;        /* Day of the week (0:Sunday, 1:Monday...) */
//     int frm_numdays;    /* Number of days in specified input  month */
//     int to_numdays;     /* Number of days in resulting output month */
//     int to_numdays2;    /* Number of days in resulting output month+1 */
//     String units;	/* Units used to denote before/after epoch */
//     String frm_dname;	/* Converting from - Name of day */
//     String frm_mname;	/* Converting from - Name of month */
//     String frm_dname_sh;	/* Converting from - Name of day   in short format */
//     String frm_mname_sh;	/* Converting from - Name of month in short format */
//     String to_dname;	/* Converting to   - Name of day */
//     String to_mname;	/* Converting to   - Name of month */
//     String to_mname2;	/* Converting to   - Name of month+1 */
//     String to_dname_sh;	/* Converting to   - Name of day   in short format */
//     String to_mname_sh;	/* Converting to   - Name of month in short format */
//     String[] event;	/* Important event pertaining to date at hand */
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         sDate that = (sDate) o;
//         return day == that.day && month == that.month && year == that.year &&
//                 weekday == that.weekday &&
//                 (units != null ? units.equals(that.units) : that.units == null);
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = day;
//         result = 31 * result + month;
//         result = 31 * result + year;
//         result = 31 * result + weekday;
//         result = 31 * result + (units != null ? units.hashCode() : 0);
//         return result;
//     }
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/util/Formatter.java
// public class Formatter {
//     public static String format(String f, Mapper mapper) {
//         NumberFormat nf = NumberFormat.getNumberInstance(Locale.ROOT);
//         nf.setGroupingUsed(false);
// 
//         StringBuilder result = new StringBuilder();
//         int count = 0;
//         boolean inQuote = false;
//         for (int i = 0, last = f.length() - 1; i <= last; ++i) {
//             char c = f.charAt(i);
//             if (i > 0 && c == f.charAt(i - 1))
//                 count++;
//             else
//                 count = 1;
// 
//             // handle quote and in-quote
//             if (c == '\'') {
//                 if (inQuote) {
//                     if (count == 2) result.append(c);
//                     inQuote = false;
//                     count = 0;
//                 } else {
//                     inQuote = true;
//                 }
//                 continue;
//             } else if (inQuote) {
//                 result.append(c);
//                 continue;
//             }
// 
//             if (i != last && c == f.charAt(i + 1)) // collect and count first
//                 continue;
// 
//             // handle format pattern and punctuation
//             if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
//                 Object val = mapper.applyFormat(c, count);
//                 if (val == null) {
//                     throw new IllegalArgumentException("Illegal pattern character '" + c + "'");
//                 } else if (val instanceof Number) {
//                     nf.setMinimumIntegerDigits(count);
//                     result.append(nf.format(val));
//                 } else {
//                     result.append(val);
//                 }
//             } else {
//                 // punctuation
//                 for (int j = 0; j < count; ++j) result.append(c);
//             }
//         }
//         return result.toString();
//     }
// 
//     public interface Mapper {
//         Object applyFormat(char pattern, int count);
//     }
// }


import java.util.Date;
import java.util.GregorianCalendar;
import org.arabeyes.itl.hijri.HijriModule.sDate;
import org.arabeyes.itl.util.Formatter;
/* Copyright (c) 2017, Fikrul Arif
 * (under LGPL license - see COPYING file)
 */
package org.arabeyes.itl.hijri;



/**
 * Represents converted date as well as the input date.
 */
@SuppressWarnings("WeakerAccess")
public class ConvertedDate implements Comparable<ConvertedDate> {

    static final int TYPE_HIJRI = 0;
    static final int TYPE_UMM_ALQURA = 1;
    static final int TYPE_GREGORIAN = 2;

// Path: itl/src/main/java/org/arabeyes/itl/hijri/HijriModule.java
// static class sDate {
//     int day;		/* Day */
//     int month;		/* Month */
//     int year;		/* Year */
//     int weekday;        /* Day of the week (0:Sunday, 1:Monday...) */
//     int frm_numdays;    /* Number of days in specified input  month */
//     int to_numdays;     /* Number of days in resulting output month */
//     int to_numdays2;    /* Number of days in resulting output month+1 */
//     String units;	/* Units used to denote before/after epoch */
//     String frm_dname;	/* Converting from - Name of day */
//     String frm_mname;	/* Converting from - Name of month */
//     String frm_dname_sh;	/* Converting from - Name of day   in short format */
//     String frm_mname_sh;	/* Converting from - Name of month in short format */
//     String to_dname;	/* Converting to   - Name of day */
//     String to_mname;	/* Converting to   - Name of month */
//     String to_mname2;	/* Converting to   - Name of month+1 */
//     String to_dname_sh;	/* Converting to   - Name of day   in short format */
//     String to_mname_sh;	/* Converting to   - Name of month in short format */
//     String[] event;	/* Important event pertaining to date at hand */
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         sDate that = (sDate) o;
//         return day == that.day && month == that.month && year == that.year &&
//                 weekday == that.weekday &&
//                 (units != null ? units.equals(that.units) : that.units == null);
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = day;
//         result = 31 * result + month;
//         result = 31 * result + year;
//         result = 31 * result + weekday;
//         result = 31 * result + (units != null ? units.hashCode() : 0);
//         return result;
//     }
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/util/Formatter.java
// public class Formatter {
//     public static String format(String f, Mapper mapper) {
//         NumberFormat nf = NumberFormat.getNumberInstance(Locale.ROOT);
//         nf.setGroupingUsed(false);
// 
//         StringBuilder result = new StringBuilder();
//         int count = 0;
//         boolean inQuote = false;
//         for (int i = 0, last = f.length() - 1; i <= last; ++i) {
//             char c = f.charAt(i);
//             if (i > 0 && c == f.charAt(i - 1))
//                 count++;
//             else
//                 count = 1;
// 
//             // handle quote and in-quote
//             if (c == '\'') {
//                 if (inQuote) {
//                     if (count == 2) result.append(c);
//                     inQuote = false;
//                     count = 0;
//                 } else {
//                     inQuote = true;
//                 }
//                 continue;
//             } else if (inQuote) {
//                 result.append(c);
//                 continue;
//             }
// 
//             if (i != last && c == f.charAt(i + 1)) // collect and count first
//                 continue;
// 
//             // handle format pattern and punctuation
//             if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
//                 Object val = mapper.applyFormat(c, count);
//                 if (val == null) {
//                     throw new IllegalArgumentException("Illegal pattern character '" + c + "'");
//                 } else if (val instanceof Number) {
//                     nf.setMinimumIntegerDigits(count);
//                     result.append(nf.format(val));
//                 } else {
//                     result.append(val);
//                 }
//             } else {
//                 // punctuation
//                 for (int j = 0; j < count; ++j) result.append(c);
//             }
//         }
//         return result.toString();
//     }
// 
//     public interface Mapper {
//         Object applyFormat(char pattern, int count);
//     }
// }


// Path: itl/src/main/java/org/arabeyes/itl/hijri/ConvertedDate.java
import java.util.Date;
import java.util.GregorianCalendar;
import org.arabeyes.itl.hijri.HijriModule.sDate;
import org.arabeyes.itl.util.Formatter;

/* Copyright (c) 2017, Fikrul Arif
 * (under LGPL license - see COPYING file)
 */
package org.arabeyes.itl.hijri;



/**
 * Represents converted date as well as the input date.
 */
@SuppressWarnings("WeakerAccess")
public class ConvertedDate implements Comparable<ConvertedDate> {

    static final int TYPE_HIJRI = 0;
    static final int TYPE_UMM_ALQURA = 1;
    static final int TYPE_GREGORIAN = 2;

    private final sDate date;