ko.bindingHandlers.dayDateSuffix = { init: (element: HTMLElement, valueAccessor: Function) => { $(element).html(ordinal(ko.unwrap(valueAccessor().value))); }, update: (element: HTMLElement, valueAccessor: Function) => { $(element).html(ordinal(ko.unwrap(valueAccessor().value))); } } as KnockoutBindingHandler; export const ordinal = (n) => { const s = ['th', 'st', 'nd', 'rd']; const v = n % 100; return n + (s[(v - 20) % 10] || s[v] || s[0]); };