### Calendar Grid (ETC) Initialization and Methods Source: https://github.com/nabute/abushakirjs/blob/master/README.md This TypeScript example illustrates the usage of the ETC class for Ethiopian calendar grids. It shows how to initialize a calendar instance and use methods like `monthDays` to get calendar information, and access properties for navigating to the next or previous month/year. ```typescript const calendar = new ETC(2011, 13, 4); calendar.monthDays(); // [2012, 7, 1, 1] calendar.monthDays(true, true); // Iterable month representation console.log(calendar.nextMonth); // ETC instance for next month console.log(calendar.prevYear); // ETC instance for same month last year ``` -------------------------------- ### Install AbushakirJs Package Source: https://github.com/nabute/abushakirjs/blob/master/README.md This command installs the AbushakirJs library using npm, making it available for use in your project. It's a prerequisite for importing and utilizing the library's functionalities. ```bash npm i abushakir ``` -------------------------------- ### Compare Ethiopian Dates using EtDatetime Methods Source: https://context7.com/nabute/abushakirjs/llms.txt Shows how to compare two Ethiopian dates using the EtDatetime class. It includes examples of boolean comparison methods like `isAfter`, `isBefore`, and `isAtSameMomentAs`, as well as a numeric comparison method `compareTo` which returns -1, 0, or 1. ```typescript import { EtDatetime } from 'abushakir'; const date1 = new EtDatetime(2016, 7, 4); const date2 = new EtDatetime(2016, 7, 26); // Boolean comparisons console.log(date2.isAfter(date1)); // true console.log(date1.isBefore(date2)); // true console.log(date1.isAtSameMomentAs(date2)); // false // Numeric comparison (-1, 0, 1) console.log(date1.compareTo(date2)); // -1 console.log(date2.compareTo(date1)); // 1 console.log(date1.compareTo(date1)); // 0 ``` -------------------------------- ### Bahire Hasab Calculations Source: https://github.com/nabute/abushakirjs/blob/master/README.md This TypeScript code demonstrates how to use the BahireHasab class for Ethiopian calendar-specific calculations. It shows how to get the Evangelist for a year, find specific feasts or fasts (like Easter or Tsom), and access all fasting periods. ```typescript const bh = new BahireHasab(2011); bh.getEvangelist(true); // => ሉቃስ bh.getSingleBealOrTsom('ትንሳኤ'); // => {month: ሚያዝያ, date: 20} const fasts = bh.allAtswamat; ``` -------------------------------- ### Convert Ethiopian to Gregorian Date Source: https://github.com/nabute/abushakirjs/blob/master/README.md This TypeScript example demonstrates how to convert an Ethiopian date object into a Gregorian `Date` object. It first creates an `EtDatetime` instance for a specific Ethiopian date and then uses its `moment` property to construct a Gregorian `Date` object, which is then formatted as an ISO string. ```typescript const etDate = new EtDatetime(2013, 1, 12); console.log(new Date(etDate.moment).toISOString()); ``` -------------------------------- ### Create and Format Ethiopian Dates with EtDatetime Source: https://context7.com/nabute/abushakirjs/llms.txt Demonstrates creating Ethiopian dates using the EtDatetime class, initializing with current time, specific dates, Unix timestamps, or full datetime components. It also shows how to format dates into ISO 8601 strings and access individual date components like year, month (numeric and Ge'ez), day, hour, minute, second, and millisecond. ```typescript import { EtDatetime } from 'abushakir'; // Create current Ethiopian date const now = new EtDatetime(); console.log(now.toIso8601String()); // 2017-03-15T14:30:45.123 // Create specific Ethiopian date (year, month, day) const date = new EtDatetime(2016, 7, 23); console.log(date.year); // 2016 console.log(date.month); // 7 (Hamle) console.log(date.day); // 23 console.log(date.monthGeez); // ሐምሌ // Create from Unix timestamp const fromTimestamp = new EtDatetime(Date.now()); // Create with full datetime (year, month, day, hour, minute, second, millisecond) const fullDate = new EtDatetime(2016, 7, 23, 14, 30, 45, 500); console.log(fullDate.hour); // 14 console.log(fullDate.minute); // 30 console.log(fullDate.second); // 45 console.log(fullDate.millisecond); // 500 ``` -------------------------------- ### Ethiopian Calendar Grid Generation (ETC) Source: https://context7.com/nabute/abushakirjs/llms.txt The `ETC` class from 'abushakir' allows for the generation and navigation of Ethiopian calendar grids. It provides methods to access date components, retrieve days of the month, and move between months and years, with options for Ge'ez numerals and weekday names. ```typescript import { ETC } from 'abushakir'; // Create calendar for specific Ethiopian date const calendar = new ETC(2016, 7, 15); // Year 2016, Month 7 (Hamle), Day 15 // Access date components console.log(calendar.year); // 2016 console.log(calendar.month); // 7 console.log(calendar.day); // 15 console.log(calendar.monthName); // ሐምሌ // Get month days as array [year, month, day, weekday] const monthDays = calendar.monthDays(); console.log(monthDays[0]); // [2016, 7, 1, 3] - first day of month // Get month with Ge'ez numerals and weekday names const geezDays = calendar.monthDays(true, true); console.log(geezDays[0]); // [2016, 7, '፩', 'ረቡዕ'] // Navigate calendar const nextMonth = calendar.nextMonth; console.log(nextMonth.month); // 8 (Nehase) const prevMonth = calendar.prevMonth; console.log(prevMonth.month); // 6 (Sene) const nextYear = calendar.nextYear; console.log(nextYear.year); // 2017 const prevYear = calendar.prevYear; console.log(prevYear.year); // 2015 // Get entire year as calendar grid const yearDays = calendar.yearDays(false, false); console.log(yearDays.length); // 13 (13 months in Ethiopian calendar) // Access calendar constants console.log(calendar.allMonths); // Array of all month names in Ge'ez console.log(calendar.dayNumbers); // Array of day numbers in Ge'ez (፩, ፪, ፫, ...) console.log(calendar.weekdays); // Array of weekday names in Ge'ez ``` -------------------------------- ### Import AbushakirJs Modules Source: https://github.com/nabute/abushakirjs/blob/master/README.md This TypeScript code demonstrates how to import essential components from the AbushakirJs library. These components include EtDatetime for date-time objects, ETC for calendar grids, BahireHasab for specific calculations, and ConvertToEthiopic for numeral conversion. ```typescript import { EtDatetime, ETC, BahireHasab, ConvertToEthiopic } from 'abushakir'; ``` -------------------------------- ### Ethiopian Orthodox Calendar Computations (BahireHasab) Source: https://context7.com/nabute/abushakirjs/llms.txt The `BahireHasab` class from 'abushakir' is designed for traditional Ethiopian Orthodox Tewahedo Church calendar computations. It calculates movable religious holidays, fasts, and feasts, and provides access to underlying computation values like Wenber and Abekte. ```typescript import { BahireHasab } from 'abushakir'; // Calculate for Ethiopian year 2016 const bh = new BahireHasab(2016); // Get Evangelist for the year console.log(bh.getEvangelist(false)); // 0, 1, 2, or 3 console.log(bh.getEvangelist(true)); // ዮሐንስ, ማቴዎስ, ማርቆስ, or ሉቃስ // Get Meskerem 1 (New Year) weekday console.log(bh.getMeskeremOne(false)); // "3" console.log(bh.getMeskeremOne(true)); // ረቡዕ (Wednesday) // Get computation values console.log(bh.ameteAlem); // Amete Alem (year of the world) console.log(bh.wenber); // Wenber value (0-18) console.log(bh.abekte); // Abekte value console.log(bh.metkih); // Metkih value // Calculate Nenewe (beginning of pre-Lenten fast) const nenewe = bh.nenewe; console.log(nenewe); // { month: 'የካቲት', date: 15 } // Get specific movable feast or fast const easter = bh.getSingleBealOrTsom('ትንሳኤ'); // Easter console.log(easter); // { month: 'ሚያዝያ', date: 20 } const holyFriday = bh.getSingleBealOrTsom('ስቅለት'); console.log(holyFriday); // { month: 'ሚያዝያ', date: 18 } // Get all movable fasts and feasts const allFeasts = bh.allAtswamat; console.log(allFeasts); // [ // { beal: 'ነነዌ', day: { month: 'የካቲት', date: 15 } }, // { beal: 'ዓቢይ ጾም', day: { month: 'የካቲት', date: 22 } }, // { beal: 'ደብረ ዘይት', day: { month: 'መጋቢት', date: 24 } }, // { beal: 'ሆሳዕና', day: { month: 'ሚያዝያ', date: 13 } }, // { beal: 'ስቅለት', day: { month: 'ሚያዝያ', date: 18 } }, // { beal: 'ትንሳኤ', day: { month: 'ሚያዝያ', date: 20 } }, // { beal: 'ርክበ ካህናት', day: { month: 'ግንቦት', date: 8 } }, // { beal: 'ዕርገት', day: { month: 'ግንቦት', date: 29 } }, // { beal: 'ጰራቅሊጦስ', day: { month: 'ሰኔ', date: 8 } }, // { beal: 'ጾመ ሐዋርያት', day: { month: 'ሰኔ', date: 9 } }, // { beal: 'ጾመ ድህነት', day: { month: 'ነሐሴ', date: 1 } } // ] // Check if a holiday is movable try { const isMovable = bh.isMovableHoliday('ትንሳኤ'); console.log(isMovable); // true } catch (error) { console.error(error.message); // Thrown if not a movable holiday } ``` -------------------------------- ### Convert Between Ethiopian and Gregorian Calendars with EtDatetime Source: https://context7.com/nabute/abushakirjs/llms.txt Demonstrates the bidirectional conversion capabilities between the Ethiopian and Gregorian calendars using the EtDatetime class. It shows how to create an Ethiopian date from a Gregorian Date object's timestamp and how to convert an Ethiopian date back to a native JavaScript Date object. Accessing the Unix timestamp and converting to a native Date object are also covered. ```typescript import { EtDatetime } from 'abushakir'; // Gregorian to Ethiopian const gregorianDate = new Date('2024-03-10T10:30:00Z'); const ethiopian = new EtDatetime(gregorianDate.getTime()); console.log(ethiopian.toIso8601String()); // 2016-07-01T10:30:00.000 // Ethiopian to Gregorian const etDate = new EtDatetime(2016, 7, 23); const gregorian = new Date(etDate.moment); console.log(gregorian.toISOString()); // 2024-03-31T... // Access Unix timestamp directly console.log(etDate.moment); // 1711843200000 console.log(etDate.valueOf()); // 1711843200000 console.log(etDate.getTime()); // 1711843200000 // Convert to native Date object const nativeDate = etDate.toDate(); console.log(nativeDate instanceof Date); // true ``` -------------------------------- ### JavaScript Date API with Ethiopian Calendar Semantics Source: https://context7.com/nabute/abushakirjs/llms.txt Utilizes the `EtDatetime` class from 'abushakir' to provide familiar JavaScript Date methods (getters, setters, string representations) with Ethiopian calendar logic. It ensures compatibility with standard Date object usage while applying Ethiopian date rules. ```typescript import { EtDatetime } from 'abushakir'; const date = new EtDatetime(2016, 7, 23, 14, 30, 45, 123); // Getters (0-indexed month for compatibility) console.log(date.getFullYear()); // 2016 console.log(date.getMonth()); // 6 (0-indexed: 7th month) console.log(date.getDate()); // 23 console.log(date.getDay()); // weekday (0-6) console.log(date.getHours()); // 14 console.log(date.getMinutes()); // 30 console.log(date.getSeconds()); // 45 console.log(date.getMilliseconds()); // 123 // Setters date.setFullYear(2017); date.setMonth(0); // 0-indexed (Meskerem) date.setDate(15); date.setHours(10); date.setMinutes(20); date.setSeconds(30); date.setMilliseconds(500); // String representations console.log(date.toString()); // ISO-8601 format console.log(date.toDateString()); // "Mon Apr 01 2024" console.log(date.toTimeString()); // "10:20:30 GMT+0000" console.log(date.toUTCString()); // "Mon, 01 Apr 2024 10:20:30 GMT" console.log(date.toLocaleString()); // Locale-specific format console.log(date.toLocaleDateString()); // Locale-specific date console.log(date.toLocaleTimeString()); // Locale-specific time ``` -------------------------------- ### Ethiopian Datetime Object Creation and Properties Source: https://github.com/nabute/abushakirjs/blob/master/README.md This TypeScript snippet shows how to create a new Ethiopian datetime object and access its date and time components. The EtDatetime object supports full date-time creation, arithmetic, comparison, ISO 8601 output, and an ECMAScript-style API. ```typescript const now = new EtDatetime(); // 2012-07-28T17:18:31.466 console.log(now.date); // { year: 2012, month: 7, day: 28 } console.log(now.time); // { h: 17, m: 18, s: 31 } ``` -------------------------------- ### Ethiopian Date Arithmetic and Comparison Source: https://github.com/nabute/abushakirjs/blob/master/README.md This TypeScript code illustrates performing date arithmetic and comparisons using the `EtDatetime` object. It calculates the difference between two Ethiopian dates in days and checks if one date is after another. ```typescript const et1 = new EtDatetime(2012, 7, 4); const et2 = new EtDatetime(2012, 7, 26); const duration = et2.difference(et1); console.log(duration.inDays); // 22 console.log(et2.isAfter(et1)); // true ``` -------------------------------- ### Convert Gregorian to Ethiopian Date Source: https://github.com/nabute/abushakirjs/blob/master/README.md This TypeScript code shows how to convert the current Gregorian date (obtained via `Date.now()`) into an Ethiopian date object using the `EtDatetime` class. It then demonstrates how to output the Ethiopian date in ISO 8601 format. ```typescript const gregorian = Date.now(); const ethiopian = new EtDatetime(gregorian); console.log(ethiopian.toIso8601String()); ``` -------------------------------- ### Perform Date Arithmetic with Duration in Ethiopian Calendar Source: https://context7.com/nabute/abushakirjs/llms.txt Illustrates how to perform date arithmetic using the Duration class with Ethiopian dates. It covers calculating the difference between two dates in various units (days, hours, minutes), adding a Duration object to a date, and subtracting a Duration object from a date. Named parameters can also be used for creating Durations. ```typescript import { EtDatetime, Duration } from 'abushakir'; const date1 = new EtDatetime(2016, 7, 4); const date2 = new EtDatetime(2016, 7, 26); // Calculate difference between dates const duration = date2.difference(date1); console.log(duration.inDays); // 22 console.log(duration.inHours); // 528 console.log(duration.inMinutes); // 31680 // Add duration to date const fiveDays = new Duration(5, 0, 0, 0, 0, 0); // days, hours, minutes, seconds, ms, μs const futureDate = date1.add(fiveDays); console.log(futureDate.day); // 9 // Subtract duration const pastDate = date2.subtract(new Duration(10, 0, 0, 0, 0, 0)); console.log(pastDate.day); // 16 // Duration with named parameters const customDuration = new Duration({ days: 2, hours: 3, minutes: 30 }); console.log(customDuration.inHours); // 51.5 ``` -------------------------------- ### Duration Operations with abushakir.js Source: https://context7.com/nabute/abushakirjs/llms.txt Manages time spans using the Duration class, supporting full arithmetic operations and conversions. It allows creation with positional or named parameters and provides methods for addition, subtraction, multiplication, division, and comparison. Durations can be formatted as strings and handle negative values. ```typescript import { Duration } from 'abushakir'; // Create duration with positional parameters (days, hours, minutes, seconds, ms, μs) const duration1 = new Duration(5, 3, 30, 45, 500, 1000); console.log(duration1.inDays); // 5.146 console.log(duration1.inHours); // 123.5126 console.log(duration1.inMinutes); // 7410.758 console.log(duration1.inSeconds); // 444645.501 console.log(duration1.inMilliseconds); // 444645501 // Create with named parameters const duration2 = new Duration({ hours: 2, minutes: 30 }); console.log(duration2.inMinutes); // 150 // Duration arithmetic const sum = duration1.add(duration2); console.log(sum.inHours); // 126.0126 const diff = duration1.subtract(duration2); console.log(diff.inHours); // 121.0126 const doubled = duration1.multiply(2); const halved = duration1.divide(2); // Comparison operations const dur1 = new Duration(2, 0, 0, 0, 0, 0); const dur2 = new Duration(1, 0, 0, 0, 0, 0); console.log(dur1.gt(dur2)); // true (greater than) console.log(dur1.gte(dur2)); // true (greater than or equal) console.log(dur2.lt(dur1)); // true (less than) console.log(dur2.lte(dur1)); // true (less than or equal) console.log(dur1.equal(dur2)); // false console.log(dur1.compareTo(dur2)); // 1 console.log(dur2.compareTo(dur1)); // -1 // Formatting console.log(duration1.toString()); // "123:30:45.501000" // Negative durations const negativeDur = new Duration(-1, 0, 0, 0, 0, 0); console.log(negativeDur.isNegative); // true console.log(negativeDur.abs().isNegative); // false ``` -------------------------------- ### Convert Arabic Numerals to Ge'ez Numerals with abushakir Source: https://context7.com/nabute/abushakirjs/llms.txt Converts standard Arabic numerals into Ethiopic (Ge'ez) numerals. This function is useful for cultural display and adheres to specific formatting rules for numbers. It supports single and batch conversions and includes error handling for invalid inputs or out-of-range numbers. ```typescript import { ConvertToEthiopic } from 'abushakir'; // Single conversions console.log(ConvertToEthiopic(1)); // ፩ console.log(ConvertToEthiopic(10)); // ፲ console.log(ConvertToEthiopic(25)); // ፳፭ console.log(ConvertToEthiopic(100)); // ፻ console.log(ConvertToEthiopic(105)); // ፻፭ console.log(ConvertToEthiopic(999)); // ፱፻፺፱ console.log(ConvertToEthiopic(9999)); // ፺፱፻፺፱ // Batch conversion const numbers = [1, 5, 10, 50, 100, 500, 1000]; const ethiopicNumerals = numbers.map(ConvertToEthiopic); console.log(ethiopicNumerals); // ['፩', '፭', '፲', '፶', '፻', '፭፻', '፲፻'] // Error handling try { ConvertToEthiopic(0); // Error: number must be > 0 ConvertToEthiopic(-5); // Error: number must be > 0 ConvertToEthiopic('123'); // TypeError: must provide Integer ConvertToEthiopic(11000); // undefined (exceeds max supported range) } catch (error) { console.error(error.message); } // Display Ethiopian date in Ge'ez numerals // Assuming EtDatetime is available and imported // const date = new EtDatetime(2016, 7, 23); // console.log(date.dayGeez); // ፳፫ // console.log(ConvertToEthiopic(date.year)); // ፳፻፲፮ ``` -------------------------------- ### Convert Arabic to Ethiopic Numerals Source: https://github.com/nabute/abushakirjs/blob/master/README.md This TypeScript snippet utilizes the `ConvertToEthiopic` function to transform an array of Arabic numerals into their Ethiopian numeral equivalents. The output shows the corresponding Ethiopic characters for the given numbers. ```typescript const nums = [1, 10, 105, 9999]; nums.map(ConvertToEthiopic); // Output: ['፩', '፲', '፻፭', '፺፱፻፺፱'] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.