adds docs
This commit is contained in:
parent
8a688d8407
commit
00accb59c4
3 changed files with 17 additions and 27 deletions
24
.github/workflows/test.yaml
vendored
24
.github/workflows/test.yaml
vendored
|
|
@ -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
|
|
||||||
|
|
@ -5,12 +5,22 @@ import * as UtilFunctionStories from './Utils.stories.svelte';
|
||||||
<Meta of={UtilFunctionStories} />
|
<Meta of={UtilFunctionStories} />
|
||||||
|
|
||||||
|
|
||||||
# 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
|
```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.'
|
||||||
```
|
```
|
||||||
|
|
@ -134,6 +134,10 @@ describe('Utils tests', () => {
|
||||||
const unformattedJune = 'Jun. 1, 2023, 10:00AM';
|
const unformattedJune = 'Jun. 1, 2023, 10:00AM';
|
||||||
const formattedJune = 'June 1, 2023, 10:00 a.m.';
|
const formattedJune = 'June 1, 2023, 10:00 a.m.';
|
||||||
expect(prettifyDate(unformattedJune)).toBe(formattedJune);
|
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', () => {
|
it('should work with lower or upper case', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue