diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index e4b171f2..00000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: Test Graphics Kit -permissions: - contents: read - issues: write -on: - push: - branches: - - main - pull_request: - branches: - - main -jobs: - build-app: - name: SvelteKit builds - strategy: - matrix: - version: [20, 22] - runs-on: ubuntu-latest - env: - TESTING: true - steps: - - id: test - name: Run tests - run: pnpm test \ No newline at end of file diff --git a/src/components/Functions/Utils.mdx b/src/components/Functions/Utils.mdx index e7f13b23..af20dd8f 100644 --- a/src/components/Functions/Utils.mdx +++ b/src/components/Functions/Utils.mdx @@ -5,12 +5,22 @@ import * as UtilFunctionStories from './Utils.stories.svelte'; -# Utils +# Util functions -Utils TKTK +This library provides utility functions that can be used across various components and applications. +## Prettify date in the Reuters format + + +The function `prettifyDate` formats the input string, which is expected to be in English, to format the month and time designator (AM/PM) according to the Reuters style guide. The function is case agnostic and will format both full month names and their 3-letter abbreviations (i.e. `Mar` or `Jun`) correctly. + ```javascript -import {prettifyDate} from '@reuters-graphics/graphics-components'; +import { prettifyDate } from '@reuters-graphics/graphics-components'; +// Example usage +prettifyDate('January 1, 2023, 10:00 AM'); // returns 'Jan. 1, 2023, 10:00 a.m.' +prettifyDate('Jan 1, 2023, 10:00 PM'); // returns 'Jan. 1, 2023, 10:00 p.m.' +prettifyDate('MAR. 2025'); // returns 'March 2025' +prettifyDate('sep. 1, 2023, 10:00PM'); // returns 'Sept. 1, 2023, 10:00 p.m.' ``` \ No newline at end of file diff --git a/src/test/utils.test.ts b/src/test/utils.test.ts index 3d120620..e60e0837 100644 --- a/src/test/utils.test.ts +++ b/src/test/utils.test.ts @@ -134,6 +134,10 @@ describe('Utils tests', () => { const unformattedJune = 'Jun. 1, 2023, 10:00AM'; const formattedJune = 'June 1, 2023, 10:00 a.m.'; expect(prettifyDate(unformattedJune)).toBe(formattedJune); + + const unformattedSept = 'sep. 1, 2023, 10:00PM'; + const formattedSept = 'Sept. 1, 2023, 10:00 p.m.'; + expect(prettifyDate(unformattedSept)).toBe(formattedSept); }); it('should work with lower or upper case', () => {