custom-parse-format
Imported from yugajs/extension/custom-parse-format.
Variables
Section titled “Variables”customParseFormat
Section titled “customParseFormat”const customParseFormat: yuga.Extension<undefined>;Day.js’s customParseFormat: strings in a format, yuga(string, format, locale?, strict?), a
list of formats (the first that parses wins), and the same in yuga.utc and yuga.tz(string, format, zone). Strings with a format are invalid without it.
- Tokens:
Y YYYY YY M MM MMM MMMM D DD Do d dd ddd dddd H HH h hh m mm s ss S SS SSS A a Q Z ZZ X x(w wwwithyugajs/extension/weeks), text in brackets is literal. Month, weekday and meridiem names are read in the locale, case-insensitively. - Missing fields default the same as Day.js (the current year, the 1st of the month, midnight), strings that don’t match are invalid, and so are unknown weekday and month names.
- Strict parsing (
trueas the last argument) makes strings that don’t format back to themselves invalid: overflowing values ("2024-02-30") and weekdays that don’t match the date. - Extensions add tokens with
yuga.$.parseTokensand rewrite formats withyuga.$.parseFormat(yugajs/extension/localized-format’sL,LT…).
import { customParseFormat } from "yugajs/extension/custom-parse-format";
yuga.extend(customParseFormat);yuga("15/05/2024", "DD/MM/YYYY");