NepaliDateFormatter

Parse and format SimpleDate for short numeric text-field input.

Use this when you have a raw YYYY/MM/DD-style string from a TextField and need a SimpleDate (or vice versa). For locale-aware long-form output ("Asar 21, 2082"), use NepaliDateConverter.formatNepaliDate(...) instead - this formatter is the primitive that backs NepaliDateTextField / NepaliDateField.

Supported Patterns are limited on purpose. A free-form DateTimeFormatter-style DSL is out of scope; the constrained surface keeps the masking and validation in the UI layer simple and predictable.

Pattern.YYYY_DASH_MM_DASH_DD with DigitScript.LATIN doubles as the library's canonical SimpleDate wire form. The optional nepali-date-picker-serialization artifact's SimpleDateSerializer emits exactly that string, so a Kotlin backend, a Swift client and a JavaScript client agree on the payload without any of them depending on kotlinx-serialization. On the way back in the serializer is the more permissive of the two: it accepts any year width, while parse holds every pattern to its fixed ten characters.

See also

for the matching HH:mm:ss time wire form.

Types

Link copied to clipboard

Supported text-field input/output patterns.

Functions

Link copied to clipboard
fun format(date: SimpleDate, pattern: NepaliDateFormatter.Pattern, script: DigitScript = DigitScript.LATIN): String

Format date as a Pattern.literal-shaped string with digits in the given script.

Link copied to clipboard

Parse input as the given pattern. Accepts Latin digits and any non-Latin digit script registered in DigitScript (Devanagari today).