@appsemble/lang-sdk
Version:
Language SDK for Appsemble
94 lines (76 loc) • 2.62 kB
JavaScript
import { schemaExample } from '../../examples.js';
export const dateRemappers = {
'date.add': {
type: 'string',
description: `Adds a specified date value to the provided date.
The value to add should be specified according to the
[](https://www.npmjs.com/package/parse-duration) API. If you want to add a day to a
date for example, the syntax would be \`date.add: 1d\`.
Full list of supported unit types:
- nanoseconds (ns)
- microseconds (μs)
- milliseconds (ms)
- seconds (s, sec)
- minutes (m, min)
- hours (h, hr)
- days (d)
- weeks (w, wk)
- months
- years (y, yr)
For example:
${schemaExample('date.add')}
`,
},
'date.format': {
oneOf: [
{ enum: [null] },
{
type: 'string',
},
],
description: `Format a date according to the RFC3339 format.
Here is an example of a RFC3339 complicit date:
\`2002-10-02T15:00:00Z\`
In an app definition, it’s best to use this when you want to display a date in a specific format.
For example, if your app has a form with a Datepicker field the incoming data will be formatted
as a simple date format. If you want to format it to the RFC3339 format, you can use this remapper.
When you submit a form with a DateField, the internal output looks like the following. You can then format the date so that it uses the RFC3339 format.
${schemaExample('date.format')}
The remapper can also be used to format a date or timestamp using a custom format.
\`\`\`js
"2023-07-02T22:00:00.000Z"
\`\`\`
You can then format the date with any supported pattern, please refer to https://date-fns.org/docs/format for the supported patterns.
\`\`\`yaml
date.format: yyyy-MM-dd
\`\`\`
Result:
\`\`\`js
2023-07-03
\`\`\`
`,
},
'date.now': {
enum: [null],
description: `Returns the current date as a JavaScript Date object.
${schemaExample('date.now', { exclude: ['input'] })}
`,
},
'date.parse': {
type: 'string',
description: `Convert a string to a date using a given format.
For example:
${schemaExample('date.parse', { exclude: ['input'] })}
See [date-fns](https://date-fns.org/v2.29.3/docs/parse) for the supported formats.
Leaving the format empty will try to parse the date using the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
For example:
\`\`\`yaml
date.parse:
- static: 2014-02-11T11:30:30
- date.parse: ''
\`\`\`
`,
},
};
//# sourceMappingURL=dates.js.map