MCPcopy
hub / github.com/tinacms/tinacms / parse

Function parse

packages/tinacms/src/toolkit/fields/plugins/date-format.ts:26–34  ·  view source on GitHub ↗
(val: string)

Source from the content-addressed store, hash-verified

24
25// parses a function from the given format to default datetime format
26export const parse = (val: string) => {
27 // allow the date to be empty
28 if (!val) return val;
29 const date = new Date(val);
30 if (!isNaN(date.getTime())) {
31 return new Date(val).toISOString();
32 }
33 return val;
34};
35
36function parseDateFormat(format: string | boolean | undefined): string {
37 if (typeof format === 'string') {

Callers 3

generateTypesFunction · 0.50
PluginFunction · 0.50
ClientClass · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected