ethiopian-date-picker-and-converter
Version:
A React component library for converting and picking Ethiopian dates.
60 lines (55 loc) • 1.98 kB
TypeScript
import React from 'react';
interface EthiopianDate {
year: number;
month: number;
day: number;
dayOfWeek: string;
}
interface DatePickerProps {
id?: string;
placeholder?: string;
onDateChange: (date: string) => void;
}
interface DateConverterResult {
ethiopianDate: EthiopianDate;
formattedDate: string;
}
declare const EthiopianDatePicker: React.FC<DatePickerProps>;
/**
* Interface representing an Ethiopian date with additional metadata
* @interface EthiopianDateObject
*/
interface EthiopianDateObject {
/** The Ethiopian year (e.g., 2016) */
year: number;
/** The Ethiopian month (1-13) */
month: number;
/** The Ethiopian day (1-30) */
day: number;
/** The name of the Ethiopian month in Amharic */
monthName: string;
/** The day of the week in Amharic */
weekDay: string;
}
/**
* Defines the format of the returned Ethiopian date
* @typedef {('full' | 'date-only' | 'object')} ReturnFormat
*/
type ReturnFormat = 'full' | 'date-only' | 'object';
/**
* Converts a Gregorian date to Ethiopian date
* @param {string} gregorianDate - The Gregorian date in 'YYYY-MM-DD' format
* @param {ReturnFormat} [returnFormat='full'] - The desired format of the returned date
* @returns {(string | EthiopianDateObject | null)} The converted Ethiopian date in the specified format
* @example
* // Returns full format (e.g., 'ሰኞ፣ ጥር 7 ቀን 2016 ዓ.ም.')
* EthiopianDateConverter('2024-01-15')
*
* // Returns date only format (e.g., '2016-5-7')
* EthiopianDateConverter('2024-01-15', 'date-only')
*
* // Returns object format
* EthiopianDateConverter('2024-01-15', 'object')
*/
declare const EthiopianDateConverter: (gregorianDate: string, returnFormat?: ReturnFormat) => string | EthiopianDateObject | null;
export { type DateConverterResult, type DatePickerProps, type EthiopianDate, EthiopianDateConverter, type EthiopianDateObject, EthiopianDatePicker, type ReturnFormat };