From c7127c22ded19e4913ad1b0645186bd40cb0536e Mon Sep 17 00:00:00 2001 From: Jan-Gerke Salomon Date: Tue, 9 Jan 2024 10:40:27 +0100 Subject: [PATCH] docs: add dev docs for "createFixedPeriodFromPeriodId" --- doc/usage/createFixedPeriodFromPeriodId.md | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 doc/usage/createFixedPeriodFromPeriodId.md diff --git a/doc/usage/createFixedPeriodFromPeriodId.md b/doc/usage/createFixedPeriodFromPeriodId.md new file mode 100644 index 0000000..69781c9 --- /dev/null +++ b/doc/usage/createFixedPeriodFromPeriodId.md @@ -0,0 +1,53 @@ +# `createFixedPeriodFromPeriodId` + +* [API](#createFixedPeriodFromPeriodId-api) +* [Examples](#createFixedPeriodFromPeriodId-examples) + + +## API + +### Signature + +```ts +type ParseFixedPeriodId = (args: { + periodId: string + calendar: SupportedCalendar + locale?: string +}) => FixedPeriod +``` + +### Arguments + +| Option | Required | Default value | Description | +|-|-|-|-| +| `periodId` | yes | - | A period id, e.g. `2020` or `2020April` | +| `calendar` | yes | - | A calendar sytem, e.g. `gregory` or `ethiopic` | +| `locale` | no | `"en"` | A language locale for the displayed labels | + +### Return value + +Returns a fixed period, see `src/period-calculation/types.ts` + + +## Examples + +```ts +createFixedPeriodFromPeriodId({ + periodId: '2023', + calendar: 'gregory', +}) +``` + +will return: + +```ts +{ + periodType: 'YEARLY', + name: '2023', + displayName: '2023', + id: '2023', + iso: '2023', + startDate: '2023-01-01', + endDate: '2023-12-31', +} +```