Spaces:
Running
Running
Download src/lib/utils.ts from cfahlgren1/sql-snippets: direct link, hf CLI and curl.
- Browser
- Download file 367 Bytes
-
https://huggingface.co/spaces/cfahlgren1/sql-snippets/resolve/main/src/lib/utils.ts
- Command line
-
hf download hf://spaces/cfahlgren1/sql-snippets/src/lib/utils.ts
-
curl -L -o utils.ts https://huggingface.co/spaces/cfahlgren1/sql-snippets/resolve/main/src/lib/utils.ts
367 Bytes
| type DateStyle = Intl.DateTimeFormatOptions['dateStyle'] | |
| export function formatDate(date: string, dateStyle: DateStyle = 'medium', locales = 'en') { | |
| // Safari is mad about dashes in the date | |
| const dateToFormat = new Date(date.replaceAll('-', '/')) | |
| const dateFormatter = new Intl.DateTimeFormat(locales, { dateStyle }) | |
| return dateFormatter.format(dateToFormat) | |
| } | |