PluginProbe
Leadpages / 1.1.2
Leadpages v1.1.2
1.3.0 1.2.1 1.2.2 1.2.3 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0
leadpages / src / utils / formatting.ts

formatting.ts in Leadpages 1.1.2, at src/utils/formatting.ts

24 lines 716 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 export const formatDate = (date: string): string => {
2 const formattedDate = new Date(date + 'Z'); // Append 'Z' to indicate UTC timezone
3
4 const options: Intl.DateTimeFormatOptions = {
5 year: 'numeric',
6 month: 'numeric',
7 day: 'numeric',
8 hour: 'numeric',
9 minute: 'numeric',
10 };
11
12 const displayDate = formattedDate.toLocaleString('en-US', options).replace(',', ' AT');
13 return displayDate;
14 };
15
16 export const formatNumber = (value: number): string => {
17 return Intl.NumberFormat('en-US').format(value);
18 };
19
20 export const formatPercentage = (value: number): string => {
21 const roundedPercentage = Math.round(value * 100);
22 return `${roundedPercentage}%`;
23 };
24