MCPcopy Index your code
hub / github.com/plotly/dash / extractFormats

Function extractFormats

components/dash-core-components/src/utils/calendar/helpers.ts:202–219  ·  view source on GitHub ↗
(format?: string)

Source from the content-addressed store, hash-verified

200 * Extracts separate month and year format strings from a combined month_format, e.g. "MMM YY".
201 */
202export function extractFormats(format?: string): {
203 monthFormat: string;
204 yearFormat: string;
205} {
206 if (!format) {
207 return {monthFormat: 'MMMM', yearFormat: 'YYYY'};
208 }
209
210 // Extract month tokens (MMMM, MMM, MM, M)
211 const monthMatch = format.match(/M{1,4}/);
212 const monthFormat = monthMatch ? monthMatch[0] : 'MMMM';
213
214 // Extract year tokens (YYYY, YY)
215 const yearMatch = format.match(/Y{2,4}/);
216 const yearFormat = yearMatch ? yearMatch[0] : 'YYYY';
217
218 return {monthFormat, yearFormat};
219}
220
221/**
222 * Generates month options for a dropdown based on a format string.

Callers 4

helpers.test.tsFile · 0.90
formatMonthFunction · 0.85
getMonthOptionsFunction · 0.85
formatYearFunction · 0.85

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…