Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions libs/shared/src/lib/utils/parser/calcFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatDate } from '@angular/common';
import { ceil, floor, round } from 'lodash';

/**
Expand Down Expand Up @@ -106,6 +107,26 @@ const calcFunctions: Record<
}
},
},
formatDate: {
signature: 'formatDate( value ; format)',
/**
* Format a date
*
* @param value The date to format
* @param format The format to use (optional, default to 'mediumDate')
* @param locale The locale to use (optional, default to the user browser locale)
* @param timezone The timezone to use (optional, default to the user browser timezone)
* @returns The formatted date
*/
call: (
value,
format = 'mediumDate',
locale = Intl.DateTimeFormat().resolvedOptions().locale, // could also be navigator.language
timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
) => {
return formatDate(value, format, locale, timezone);
},
},
};

export default calcFunctions;