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' ;
1
2
import { ceil , floor , round } from 'lodash' ;
2
3
3
4
/**
@@ -90,6 +91,26 @@ const calcFunctions: Record<
90
91
return percent . toFixed ( parsedPrecision ) + '%' ;
91
92
} ,
92
93
} ,
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
+ } ,
93
114
} ;
94
115
95
116
export default calcFunctions ;
You can’t perform that action at this time.
0 commit comments