formatEnglishDateTimeByUnicodePattern
Formats an English date and time based on the specified Unicode pattern and language preferences.
Return
A string representing the formatted date and time according to the provided Unicode pattern and language preferences.
The function supports the following placeholders in the unicodePattern:
yyyy: Four-digit year (e.g., "2025" or "२०२५")yy: Two-digit year (e.g., "25" or "२५")MMMM: Full month name (e.g., "January" or "जनवरी")MMM: Abbreviated month name (e.g., "Jan" or "जन")MM: Two-digit month (e.g., "01" or "०१")M: Month number, no padding (e.g., "1" or "१")dd: Two-digit day of month (e.g., "04" or "०४")d: Day of month, no padding (e.g., "4" or "४")D: Day of the year (1–366) (e.g., "123" or "१२३")w: Week of the year (e.g., "23" or "२३")EEEE: Full weekday name (e.g., "Monday" or "सोमबार")E: Medium weekday name (e.g., "Mon" or "सोम")EEEEE: Short weekday name, if defined (e.g., "M" or "स")ee: Two-digit day of week (e.g., "02" or "०२")e: Day of week, no padding (e.g., "2" or "२")HH: Hour in 24-hour format (00–23) (e.g., "08" or "०८")H: Hour in 24-hour format, no padding (e.g., "8" or "८")hh: Hour in 12-hour format (01–12) (e.g., "01" or "०१")h: Hour in 12-hour format, no padding (e.g., "1" or "१")mm: Minutes, two-digit (e.g., "05" or "०५")m: Minutes, no padding (e.g., "5" or "५")ss: Seconds, two-digit (e.g., "09" or "०९")s: Seconds, no padding (e.g., "9" or "९")SSSS: Four-digit nanosecond precision (e.g., "1234" or "१२३४")SSS: Millisecond precision (e.g., "123" or "१२३")SS: Two-digit fractional seconds (e.g., "12" or "१२")S: One-digit fractional second (e.g., "1" or "१")a: Lowercase AM/PM or localized period (e.g., "am" or "बिहान")A: Uppercase AM/PM or localized period (e.g., "AM" or "साँझ")
Example usage:
val calendar = CustomCalendar(year = 2025, month = 5, dayOfMonth = 14, dayOfWeek = 3,...)
val time = SimpleTime(hour = 15, minute = 30, second = 45, nanosecond = 123)
val formattedDateTime = formatEnglishDateTimeByUnicodePattern(
"yyyy-MM-dd EEEE hh:mm:ss a",
calendar,
time
)
// formattedDateTime: "2025-05-14 Tuesday 03:30:45 PM"Parameters
A CustomCalendar representing the date.
An optional SimpleTime that holds the time details (hour, minute, second, nanosecond). If not provided, the time part will be omitted in the formatted string.
A string specifying the pattern to use for formatting the date and time. The pattern supports various placeholders like "yyyy", "MM", "dd", "hh", "mm", "ss", etc.
The NepaliDatePickerLang specifying the language for formatting the date and time. Defaults to NepaliDatePickerLang.ENGLISH, which uses English month and weekday names.