MCPcopy Create free account
hub / github.com/eclipsesource/jsonforms / convertDateToString

Function convertDateToString

packages/core/src/util/util.ts:60–76  ·  view source on GitHub ↗
(
  date: Date,
  format?: 'date' | 'time' | 'date-time'
)

Source from the content-addressed store, hash-verified

58 * convertDateToString(new Date('2023-11-09T14:22:54.131Z'));
59 */
60export const convertDateToString = (
61 date: Date,
62 format?: 'date' | 'time' | 'date-time'
63): string => {
64 //e.g. '2023-11-09T14:22:54.131Z'
65 const dateString = date.toISOString();
66 if (format === 'date-time') {
67 return dateString;
68 } else if (format === 'date') {
69 // e.g. '2023-11-09'
70 return dateString.split('T')[0];
71 } else if (format === 'time') {
72 //e.g. '14:22:54'
73 return dateString.split('T')[1].split('.')[0];
74 }
75 return dateString;
76};
77
78/**
79 * Escape the given string such that it can be used as a class name,

Callers 3

renderer.test.tsFile · 0.90
doCreateDefaultValueFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…