Skip to content

Commit

Permalink
feat: get all supported calendars and currency (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-sharma7 authored Oct 18, 2024
1 parent 0f39415 commit 813cad0
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
- [Get Current Time in Zone](./guide/getCurrentTimeInZone.md)
- [Get list of Time Zones](./guide/getListOfSupportedTimeZones.md)
- [Get Count Down To Event](./guide//getCountdownToEvent.md)
- [Get list of calendar](./guide/getSupportedCalendar.md)
- [Get list of Currency](./guide/getSupportedCrrency.md)
- [Convert Time Zone](./guide/convertTimeZone.md)
- [Time Zone Offset Difference](./guide/getTimeZoneOffsetDifference.md)
- [Format Date in Time Zone](./guide/formatDateInTimeZone.md)
Expand Down
33 changes: 33 additions & 0 deletions docs/guide/getSupportedCalendar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Supported Timezones

## Description

This function returns a list of all supported calendars, making it easy to access and work with timezone data and calender.

## Usage

```javascript
import { getSupportedCalendar } from 'world-clockify';

const calendar = getSupportedCalendar();
```

## Expected Output

```bash

'buddhist', 'chinese',
'coptic', 'dangi',
'ethioaa', 'ethiopic',
'gregory', 'hebrew',
'indian', 'islamic',
'islamic-civil', 'islamic-rgsa',
'islamic-tbla', 'islamic-umalqura',
'iso8601', 'japanese',
'persian', 'roc'

```

## Returns

Returns: strings[], Array of string each representing supported calendar.
34 changes: 34 additions & 0 deletions docs/guide/getSupportedCrrency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Supported Currency

## Description

This function returns a list of all supported currencies, making it easy to access and work with currency data.

## Usage

```javascript
import { getSupportedCrrency } from 'world-clockify';

const currency = getSupportedCrrency();
```

## Expected Output

```bash

'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD',
'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF',
'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN',
'BZD', 'CAD', 'CDF', 'CHF', 'CLP', 'CNY', 'COP', 'CRC',
'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD',
'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL',
'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL',
'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR',
'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF',
... more items

```

## Returns

Returns: strings[], Array of string each representing supported currency.
20 changes: 20 additions & 0 deletions src/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,26 @@ export const getSupportedTimezones = (): string[] => {
return getListOfSupportedTimeZones;
};

/**
* Returns a list of all supported currency using the Javascript Intl API.
* @returns {string[]} - An array of supported currency strings.
*/
export const getSupportedCrrency = (): string[] => {
const getListOfSupportedCurrency = Intl.supportedValuesOf('currency');

return getListOfSupportedCurrency;
};

/**
* Returns a list of all supported calendar using the Javascript Intl API.
* @returns {string[]} - An array of supported calendar strings.
*/
export const getSupportedCalendar = (): string[] => {
const getListOfSupportedCalendar = Intl.supportedValuesOf('calendar');

return getListOfSupportedCalendar;
};

/**
* Get the countdown to a specific event in a given timezone.
*
Expand Down
12 changes: 12 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
formatDateInTimeZone,
calculateDuration,
getSupportedTimezones,
getSupportedCrrency,
getSupportedCalendar,
getCountdownToEvent,
} from '../src/function.js';

Expand Down Expand Up @@ -71,6 +73,16 @@ describe('Timezone-Aware Date Helper', () => {
expect(timezones).toBeInstanceOf(Array);
});

it('should returns a list of all supported currency', () => {
const currencies = getSupportedCrrency();
expect(currencies).toBeInstanceOf(Array);
});

it('should returns a list of all supported calendar', () => {
const calenders = getSupportedCalendar();
expect(calenders).toBeInstanceOf(Array);
});

it('should calculate the countdown to a specific event', () => {
const eventDate = '2024-10-20T15:00:00';
const eventTimezone = 'America/New_York';
Expand Down

0 comments on commit 813cad0

Please sign in to comment.