File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
libs/shared/src/lib/utils/parser Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ import { formatDate } from '@angular/common' ;
12import { ceil , floor , round } from 'lodash' ;
23
34/**
@@ -90,6 +91,26 @@ const calcFunctions: Record<
9091 return percent . toFixed ( parsedPrecision ) + '%' ;
9192 } ,
9293 } ,
94+ formatDate : {
95+ signature : 'formatDate( value ; format)' ,
96+ /**
97+ * Format a date
98+ *
99+ * @param value The date to format
100+ * @param format The format to use (optional, default to 'mediumDate')
101+ * @param locale The locale to use (optional, default to the user browser locale)
102+ * @param timezone The timezone to use (optional, default to the user browser timezone)
103+ * @returns The formatted date
104+ */
105+ call : (
106+ value ,
107+ format = 'mediumDate' ,
108+ locale = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . locale , // could also be navigator.language
109+ timezone = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone
110+ ) => {
111+ return formatDate ( value , format , locale , timezone ) ;
112+ } ,
113+ } ,
93114} ;
94115
95116export default calcFunctions ;
You can’t perform that action at this time.
0 commit comments