Skip to content

Commit

Permalink
fix(core/models): accept string input in formatDate validation helper
Browse files Browse the repository at this point in the history
needed for backward compatibility
  • Loading branch information
trik committed Mar 16, 2020
1 parent 9494446 commit 9229731
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/models/utils/validation-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,10 @@ export function formatNumber(num: number, fmt?: string): string {
return numeralConstructor(num).format(fmt);
}

export function formatDate(date: Date, fmt?: string): string {
fmt = fmt || 'mm-dd-yyyy';
return dateUtils.format(date, fmt);
export function formatDate(date: Date|string, fmt?: string): string {
fmt = fmt || 'mm-DD-yyyy';
return dateUtils.format(
typeof date === 'string' ? dateUtils.parse(date) : date, fmt);
}

export function isoMonth(date: Date, fmt?: string): string {
Expand Down

0 comments on commit 9229731

Please sign in to comment.