Skip to Content
Kenat is a work in progress project ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป
Documentation๐Ÿ–Œ๏ธ Formatting

Formatting Ethiopian Dates with Kenat

The kenat.formatting module provides a collection of functions to format Kenat date objects into various string representations. You can combine these with the Time class for time-aware formatting.


Formatting Functions

Here are the primary functions available for formatting dates in Python.

format_standard(et_date, lang='amharic')

Formats a date into a standard "Month Day Year" string.

undefined

import { Kenat } from 'kenat'; const today = new Kenat(2016, 1, 10); // Default Amharic output console.log(today.format('MMMM D YYYY')); // Output: แˆ˜แˆตแŠจแˆจแˆ 10 2016 // English output console.log(today.format('MMMM D YYYY', { lang: 'en' })); // Output: Meskerem 10 2016

format_with_weekday(et_date, lang='amharic', use_geez=False)

Includes the day of the week in the output.

import { Kenat } from 'kenat'; const today = new Kenat(2016, 1, 10); // Weekday in Amharic console.log(today.format('dddd, MMMM D YYYY')); // Output: แˆ›แŠญแˆฐแŠž, แˆ˜แˆตแŠจแˆจแˆ 10 2016 // Weekday with Geez numerals console.log(today.format('dddd, MMMM D YYYY', { useGeez: true })); // Output: แˆ›แŠญแˆฐแŠž, แˆ˜แˆตแŠจแˆจแˆ แฒ แณแปแฒแฎ

format_with_time(et_date, time_obj, lang='amharic')

Combines a date and a Time object into a single string.

import { Kenat } from 'kenat'; const today = new Kenat(2016, 1, 10, 8, 30); console.log(today.format('MMMM D YYYY h:mm A')); // Output: แˆ˜แˆตแŠจแˆจแˆ 10 2016 8:30 แ‰€แŠ•

format_in_geez_amharic(et_date)

Formats the date using Geโ€™ez numerals for the day and year.

import { Kenat } from 'kenat'; const today = new Kenat(2016, 1, 10); console.log(today.format('MMMM D YYYY', { useGeez: true })); // Output: แˆ˜แˆตแŠจแˆจแˆ แฒ แณแปแฒแฎ

format_short(et_date)

Returns the date in a compact YYYY/MM/DD format.

import { Kenat } from 'kenat'; const today = new Kenat(2016, 1, 10); console.log(today.format('YYYY/MM/DD')); // Output: 2016/01/10

to_iso_date_string(et_date, time_obj=None)

Returns an ISO-like string, with optional time.

import { Kenat } from 'kenat'; // Date only const today = new Kenat(2016, 1, 10); console.log(today.toISOString()); // Output: 2016-01-10 // With time const withTime = new Kenat(2016, 1, 10, 8, 30); console.log(withTime.toISOString()); // Output: 2016-01-10T08:30
Last updated on