-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(formatters): add all missing Date Formatters (#855)
- Loading branch information
1 parent
30b80e2
commit 9d29e59
Showing
14 changed files
with
450 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateEuroShortFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateEuroShort Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateEuroShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateEuroShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateEuroShort(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateEuroShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateEuroShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeEuroAM_PMFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeEuroAM_PM Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('01/05/2019 02:36:07 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('01/05/2019 02:36:07 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('01/05/2019 08:36:07 PM'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeEuroShortAM_PMFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeEuroShortAM_PM Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 2:36:7 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 2:36:7 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 8:36:7 PM'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeEuroShortAmPmFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeEuroShortAmPm Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 2:36:7 am'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 2:36:7 am'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 8:36:7 pm'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeEuroShortFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeEuroShort Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeEuroShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeEuroShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeEuroShort(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 2:36:7'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeEuroShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 2:36:7'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeEuroShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('1/5/19 20:36:7'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeIsoAM_PMFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeIsoAM_PM Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('2019-05-01 02:36:07 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('2019-05-01 02:36:07 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('2019-05-01 08:36:07 PM'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeUsAM_PMFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeUsAM_PM Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeUsAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeUsAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeUsAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('05/01/2019 02:36:07 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeUsAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('05/01/2019 02:36:07 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeUsAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('05/01/2019 08:36:07 PM'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeUsShortAM_PMFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeUsShortAM_PM Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 2:36:7 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 2:36:7 AM'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 8:36:7 PM'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeUsShortAmPmFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeUsShortAmPm Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 2:36:7 am'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 2:36:7 am'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 8:36:7 pm'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateTimeUsShortFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateTimeUsShort Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateTimeUsShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateTimeUsShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateTimeUsShort(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 2:36:7'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateTimeUsShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 2:36:7'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateTimeUsShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19 20:36:7'); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/common/src/formatters/__tests__/dateUsShortFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { Formatters } from '../index'; | ||
|
||
describe('the DateUsShort Formatter', () => { | ||
it('should return null when no value is provided', () => { | ||
const value = null; | ||
const result = Formatters.dateUsShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should return original string when input value provided is not a valid date', () => { | ||
const value = 'TBD'; | ||
const result = Formatters.dateUsShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('TBD'); | ||
}); | ||
|
||
it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => { | ||
const value = '2019-05-01 02:36:07'; | ||
const result = Formatters.dateUsShort(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19'); | ||
}); | ||
|
||
it('should return a formatted date value in the morning when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T02:36:07'); | ||
const result = Formatters.dateUsShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19'); | ||
}); | ||
|
||
it('should return a formatted date value in the afternoon when valid date value is provided', () => { | ||
const value = new Date('2019-05-01T20:36:07'); | ||
const result = Formatters.dateUsShort(0, 0, value, {} as Column, {}, {} as any); | ||
expect(result).toBe('5/1/19'); | ||
}); | ||
}); |
Oops, something went wrong.