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.
undefined
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.
undefined
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.
undefined
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.
undefined
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.
undefined
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