Fix formatdate not allowing strings (#37301) (#37557)

* Fix formatdate not allowing strings

* Addressing Feedback
This commit is contained in:
Clint Andrew Hall 2019-06-06 00:09:00 -05:00 committed by GitHub
parent 80038e3c8e
commit 5170349676
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -12,7 +12,7 @@ interface Arguments {
format: string;
}
export function formatdate(): ContextFunction<'formatdate', number, Arguments, string> {
export function formatdate(): ContextFunction<'formatdate', number | string, Arguments, string> {
const { help, args: argHelp } = getFunctionHelp().formatdate;
return {
@ -20,7 +20,7 @@ export function formatdate(): ContextFunction<'formatdate', number, Arguments, s
type: 'string',
help,
context: {
types: ['number'],
types: ['number', 'string'],
},
args: {
format: {

View file

@ -11,9 +11,12 @@ import { FunctionFactory } from '../../functions/types';
export const help: FunctionHelp<FunctionFactory<typeof formatdate>> = {
help: i18n.translate('xpack.canvas.functions.formatdateHelpText', {
defaultMessage: 'Output a {ms} since epoch number as a formatted string',
defaultMessage:
'Format a valid date string or number of {ms} since epoch using {moment} (see {url})',
values: {
ms: 'ms',
moment: 'momentJS',
url: 'https://momentjs.com/',
},
}),
args: {