Skip to Content
Kenat is a work in progress project 👨🏻‍💻
Documentation⚙️ Kenat Class

⚙️ Kenat Class

The Kenat class provides a high-level API for working with Ethiopian calendar dates. You can create instances, format dates, manipulate them, and print calendars.


🏗 Constructor

new Kenat(dateStringOrDict?)

Creates a new instance of an Ethiopian date.

  • If no argument is passed, it uses the current Gregorian system date.
  • If a string like '2015/6/10' is passed, it’s parsed as an Ethiopian date.
  • It can also be initialized with a dictionary: {'year': 2015, 'month': 6, 'day': 10}.

undefined

const k = new Kenat(); const custom = new Kenat('2016/6/10');

📆 Date Access & Formatting

Multiple methods are available to get the date in different formats.

MethodReturnsDescription
get_ethiopian(){ 'year', 'month', 'day' }Get the Ethiopian date as a dictionary.
get_gregorian(){ 'year', 'month', 'day' }Get the equivalent Gregorian date.
__str__()"YYYY/MM/DD"A simple string representation.
format_standard(lang='amharic')"መስከረም 5 2016" or similarHuman-readable string with language options.
format_in_geez_amharic()"መስከረም ፭ ፳፻፲፮"Geez-styled output.
format_with_weekday(lang, use_geez)"ማክሰኞ, መስከረም 1 2016"Includes the day of the week.
format_with_time(time_obj, lang)"መስከረም 10 2016 08:30 ጠዋት"Combines date and a Time object.
to_iso_date_string(time_obj)"YYYY-MM-DDTHH:mm"ISO 8601-like format.
const k = new Kenat('2016/1/5'); console.log(k.getEthiopian()); // { year: 2016, month: 1, day: 5 } console.log(k.toString()); // Ethiopian: 2016-1-5 console.log(k.formatInGeezAmharic()); // መስከረም ፭ ፳፻፲፮

🕒 Time Handling

The Time class handles time calculations, conversions, and formatting separately from the date.

Method/ClassDescription
Time(hour, min, period)Creates a time object (e.g., 3:30, ‘night’).
Time.from_gregorian(h, m)Creates an Ethiopian Time object from Gregorian 24h time.
time.to_gregorian()Converts Ethiopian time back to a 24h dictionary.
time.format()Formats the time into a string (e.g., “፫:፴ ሌሊት”).
time.add(duration)Adds hours/minutes to the time.
time.diff(other_time)Calculates the difference between two Time objects.
const k = new Kenat(); console.log(k.getCurrentTime());

➕ Date Arithmetic

These functions are available in the kenat.day_arithmetic module and take a Kenat object as the first argument.

FunctionDescription
add_days(date, n)Returns a new date n days away.
add_months(date, n)Returns a new date n months away.
add_years(date, n)Returns a new date n years away.
const k = new Kenat('2014/5/5'); k.addDays(10); k.addMonths(-1); console.log(k.getEthiopian());

📏 Compare Dates

These functions take two Kenat objects and return the difference. They are available in the kenat.day_arithmetic module.

FunctionDescription
diff_in_days(a, b)Calculates the total day difference.
diff_in_months(a, b)Calculates the month difference.
diff_in_years(a, b)Calculates the year difference.
const a = new Kenat('2015/6/10'); const b = new Kenat('2012/6/10'); console.log(a.diffInYears(b)); // → 3

🗓 Calendar & Holiday Tools

The library includes powerful tools for generating monthly calendars and retrieving holiday information.

Method/ClassDescription
MonthGrid(config)A class to generate a grid for a specific month.
get_holiday(key, year, lang)Get details for a single holiday.
get_holidays_in_month(y, m)Get all holidays in a given month.
get_holidays_for_year(year)Get all holidays for a given year.
const k = new Kenat('2016/1/1'); k.printThisMonth(true);
Last updated on