Skip to content
GitHub

Modules

Dates

Write Gregorian dates in Malagasy and get the Malagasy names of months and weekdays, in five styles.

  • formatDate('2026-11-23')23 Novambra 2026
  • formatDate('2026-11-23', 'full')Alatsinainy 23 Novambra 2026
  • spellTime('07:15')amin'ny fito sy dimy ambin'ny folo minitra maraina
  • spellTime('14:30')amin'ny roa sy telopolo minitra tolakandro
  • spellTime('21:00')amin'ny sivy alina

Result

Alahady 26 Jona 1960

JSformatDate('1960-06-26', 'full')PHPMalagasyDate::fromString('1960-06-26')->format(DateStyle::Full)
Open in the playground →
formatDate(date, style)Date → text in a DateStyle
parseDate(text, style)Malagasy date text → date, or throws
safeParseDate(text, style)Text → date or error code, never throws
tryParseDate(text, style)Text → date, or nothing, never throws
spellTime(time)Time → Malagasy words
parseTime(text)Words → time, or throws
safeParseTime(text)Words → time or error code, never throws
tryParseTime(text)Words → time, or nothing, never throws
spellDateTime(dateTime, style)Date and time → date, then time in words
monthName(month, width)1–12 → month name, wide or abbreviated
weekdayName(isoWeekday, width)ISO weekday 1–7 → name, wide or abbreviated
Results computed by the library
CaseCallResult
longformatDate('2026-11-23', 'long')23 Novambra 2026
fullformatDate('2026-11-23', 'full')Alatsinainy 23 Novambra 2026
mediumformatDate('2026-11-23', 'medium')2026 Nov 23
shortformatDate('2026-11-23', 'short')2026-11-23
numericformatDate('2026-11-23', 'numeric')23/11/2026
import { formatDate } from '@mdgascar/date-time';
formatDate('2026-11-23'); // '23 Novambra 2026'
formatDate('2026-11-23', 'full'); // 'Alatsinainy 23 Novambra 2026'
formatDate({ year: 1960, month: 6, day: 26 }, 'full'); // 'Alahady 26 Jona 1960'
formatDate(new Date(), 'numeric');

parseDate reads back every style formatDate writes. Case and extra spaces do not matter, and day and month may have one digit.

Examples

Result

{ year: 2026, month: 11, day: 23 }

JSparseDate('23 Novambra 2026')PHPMalagasyDate::parse('23 Novambra 2026')
Open in the playground →
import { parseDate } from '@mdgascar/date-time';
parseDate('23 Novambra 2026'); // { year: 2026, month: 11, day: 23 }
parseDate('23/11/2026'); // { year: 2026, month: 11, day: 23 }

spellTime says a time of day in Malagasy: the hour on a 12-hour clock, then sy and the minutes counted with minitra, then the part of the day (alina 0–3 and 20–23, maraina 4–11, atoandro 12, tolakandro 13–17, hariva 18–19). parseTime reads it back.

Parts of the day
Part of the dayHoursExample
alina00:00 – 03:59amin'ny roa ambin'ny folo alina
maraina04:00 – 11:59amin'ny efatra maraina
atoandro12:00amin'ny roa ambin'ny folo atoandro
tolakandro13:00 – 17:59amin'ny iray tolakandro
hariva18:00 – 19:59amin'ny enina hariva
alina20:00 – 23:59amin'ny valo alina
Examples

Result

amin'ny roa sy telopolo minitra tolakandro

JSspellTime('14:30')PHPMalagasyTime::fromString('14:30')->spell()
Open in the playground →
import { parseTime, spellTime } from '@mdgascar/date-time';
spellTime('07:15'); // "amin'ny fito sy dimy ambin'ny folo minitra maraina"
spellTime('14:30'); // "amin'ny roa sy telopolo minitra tolakandro"
spellTime('17:45'); // "amin'ny dimy sy dimy amby efapolo minitra tolakandro"
parseTime("amin'ny roa sy telopolo minitra tolakandro"); // { hour: 14, minute: 30 }

spellDateTime writes the date in a date style, then the time in words.

Examples

Result

23 Novambra 2026 amin'ny roa sy telopolo minitra tolakandro

JSspellDateTime('2026-11-23T14:30')PHPMalagasyDateTime::fromString('2026-11-23T14:30')->spell()
Open in the playground →
import { spellDateTime } from '@mdgascar/date-time';
spellDateTime('2026-11-23T14:30'); // "23 Novambra 2026 amin'ny roa sy telopolo minitra tolakandro"
spellDateTime('2026-11-23T14:30', 'full'); // "Alatsinainy 23 Novambra 2026 amin'ny roa sy telopolo minitra tolakandro"

Weekdays use ISO numbers: Monday is 1, Sunday is 7.

import { monthName, weekdayName } from '@mdgascar/date-time';
monthName(6); // 'Jona'
monthName(6, 'abbreviated'); // 'Jon'
weekdayName(1); // 'Alatsinainy'
weekdayName(7, 'abbreviated'); // 'Alah'
Input Error code
A date that is not a string, Date or { year, month, day }; a month or weekday that is not a whole number INVALID_TYPE
Not a real calendar date (2026-02-30) INVALID_FORMAT
Month outside 1–12, weekday outside 1–7 OUT_OF_RANGE