โ๏ธ 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(dateString?)
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.
undefined
const k = new Kenat();
const custom = new Kenat('2016/6/10');
๐ Date Access Methods
Method | Returns | Description |
---|---|---|
getEthiopian() | { year, month, day } | Current Ethiopian date |
getGregorian() | { year, month, day } | Equivalent Gregorian date |
toString() | "Ethiopian: yyyy-mm-dd" | String format |
format(lang?) | "แแตแจแจแ 5 2016" or similar | Human-readable string |
formatInGeezAmharic() | "แแตแจแจแ แญ แณแปแฒแฎ" | Geez-styled output |
๐ Time Handling
Method | Description |
---|---|
getCurrentTime() | Gets current time in Ethiopian format |
setTime(hour, min, period) | Sets Ethiopian time manually (e.g., 3:30 night) |
โ Date Arithmetic
Method | Description |
---|---|
addDays(n) | Move n days forward/backward |
addMonths(n) | Adjust by n Ethiopian months |
addYears(n) | Move by n Ethiopian years |
const k = new Kenat('2014/5/5');
k.addDays(10);
k.addMonths(-1);
console.log(k.getEthiopian());
๐ Compare Dates
Method | Description |
---|---|
diffInDays(other) | Day difference |
diffInMonths(other) | Month difference |
diffInYears(other) | Year difference |
const a = new Kenat('2015/6/10');
const b = new Kenat('2012/6/10');
console.log(a.diffInYears(b)); // โ 3
๐ Calendar Tools
Method | Description |
---|---|
getMonthCalendar() | Full info for every day in the current month |
printThisMonth(useGeez?) | Console grid printer for current month |
const k = new Kenat('2016/1/1');
k.printThisMonth(true);
Last updated on