Skip to content

Commit

Permalink
Add additional date formats (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsaffran authored Jan 26, 2022
1 parent 89caa3d commit 9a8d9d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ import Decimal from 'decimal.js';

export const EMPTY_FIELD = '--';

export const DATE_FORMATS: { date: string; date_at_time: string; date_value: string } = {
export const DATE_FORMATS: {
date: string;
date_at_time: string;
date_value: string;
written_date: string;
written_date_abbreviated: string;
} = {
date: 'LL/dd/yy',
date_at_time: 'LL/dd/yy @ h:mma', // ex. 07/14/16 @ 2:24PM
date_value: 'yyyy-LL-dd',
written_date: 'MMMM d, yyyy',
written_date_abbreviated: 'MMM d, yyyy',
};

export const CENT_DECIMAL = new Decimal('100');
Expand Down
4 changes: 3 additions & 1 deletion test/formatting.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as util from '../src';
import { EMPTY_FIELD } from '../src';
import { DATE_FORMATS, EMPTY_FIELD } from '../src';

const EMPTY_VALUES = [' ', ' ', '', null, undefined];

Expand Down Expand Up @@ -216,6 +216,8 @@ describe('formatting', () => {

it('formatDate', () => {
expect(util.formatDate('2016-10-03')).toBe('10/03/16');
expect(util.formatDate('2016-10-03', DATE_FORMATS.written_date)).toBe('October 3, 2016');
expect(util.formatDate('2016-10-03', DATE_FORMATS.written_date_abbreviated)).toBe('Oct 3, 2016');
});

it('formatDateTime', () => {
Expand Down

0 comments on commit 9a8d9d9

Please sign in to comment.