Skip to content

Commit

Permalink
Document formatDate and formatTime
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuprog committed Sep 2, 2023
1 parent deca168 commit 345ebb2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,18 @@ import { useLocale } from 'solid-compose';
const [locale, { setDateFormat }] = useLocale();
```

`formatDate` allows to format a date according to the current locale's date formatting setting.

```typescript
import { formatDate, useLocale } from 'solid-compose';
const [locale, { setDateFormat }] = useLocale();
setDateFormat({ endianness: DateEndianness.MiddleEndian });
formatDate(Temporal.PlainDate.from('2000-12-31')) // 12/31/2000
```

### Time format

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

`formatTime` allows to format a time according to the current locale's time formatting setting.

```typescript
import { formatTime, useLocale } from 'solid-compose';
const [locale, { setTimeFormat }] = useLocale();
setTimeFormat({ is24HourClock: false });
formatTime(Temporal.PlainTime.from('00:30:05'), { precision: 'minute', omitZeroUnits: true }) // 12:30 AM
```

### Time zone

`setTimeZone` allows to change the time zone:
Expand Down

0 comments on commit 345ebb2

Please sign in to comment.