Skip to content

Commit 345ebb2

Browse files
committed
Document formatDate and formatTime
1 parent deca168 commit 345ebb2

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,18 @@ import { useLocale } from 'solid-compose';
386386
const [locale, { setDateFormat }] = useLocale();
387387
```
388388

389+
`formatDate` allows to format a date according to the current locale's date formatting setting.
390+
391+
```typescript
392+
import { formatDate, useLocale } from 'solid-compose';
393+
394+
const [locale, { setDateFormat }] = useLocale();
395+
396+
setDateFormat({ endianness: DateEndianness.MiddleEndian });
397+
398+
formatDate(Temporal.PlainDate.from('2000-12-31')) // 12/31/2000
399+
```
400+
389401
### Time format
390402

391403
`setTimeFormat` allows to change the time format:
@@ -396,6 +408,18 @@ import { useLocale } from 'solid-compose';
396408
const [locale, { setTimeFormat }] = useLocale();
397409
```
398410

411+
`formatTime` allows to format a time according to the current locale's time formatting setting.
412+
413+
```typescript
414+
import { formatTime, useLocale } from 'solid-compose';
415+
416+
const [locale, { setTimeFormat }] = useLocale();
417+
418+
setTimeFormat({ is24HourClock: false });
419+
420+
formatTime(Temporal.PlainTime.from('00:30:05'), { precision: 'minute', omitZeroUnits: true }) // 12:30 AM
421+
```
422+
399423
### Time zone
400424

401425
`setTimeZone` allows to change the time zone:

0 commit comments

Comments
 (0)