Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateEuro Formatter', () => {

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-03 00:00:01';
const result = Formatters.dateEuro(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateEuro(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('03/05/2019');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('the Date ISO Formatter', () => {

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-03 00:00:01';
const result = Formatters.dateIso(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateIso(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('2019-05-03');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeShortEuro Formatter', () => {

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.dateTimeEuroAmPm(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeEuroAmPm(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('01/05/2019 02:36:07 am');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeEuro Formatter', () => {

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.dateTimeEuro(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeEuro(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('01/05/2019 02:36:07');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeIsoAmPm Formatter', () => {

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.dateTimeIsoAmPm(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeIsoAmPm(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('2019-05-01 02:36:07 am');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeIso Formatter', () => {

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.dateTimeIso(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeIso(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('2019-05-01 02:36:07');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeShortEuro Formatter', () => {

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.dateTimeShortEuro(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeShortEuro(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('01/05/2019 02:36');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeShortIso Formatter', () => {

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.dateTimeShortIso(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeShortIso(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('2019-05-01 02:36');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeShortUs Formatter', () => {

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-03 02:36:07';
const result = Formatters.dateTimeShortUs(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeShortUs(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('05/03/2019 02:36');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeShortUs Formatter', () => {

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-03 02:36:07';
const result = Formatters.dateTimeUsAmPm(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeUsAmPm(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('05/03/2019 02:36:07 am');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateTimeUs Formatter', () => {

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-03 02:36:07';
const result = Formatters.dateTimeUs(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateTimeUs(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('05/03/2019 02:36:07');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('the DateUs Formatter', () => {

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-03';
const result = Formatters.dateUs(0, 0, value, { input: 'dateIso' } as unknown as Column, {}, {});
const result = Formatters.dateUs(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {});
expect(result).toBe('05/03/2019');
});

Expand Down
12 changes: 6 additions & 6 deletions src/app/modules/angular-slickgrid/sorters/dateUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ const moment = moment_; // patch to fix rollup "moment has no default export" is
export function compareDates(value1: any, value2: any, sortDirection: number, sortColumn: Column, gridOptions: GridOption, format: string | moment_.MomentBuiltinFormat, strict?: boolean) {
let diff = 0;
const checkForUndefinedValues = sortColumn && sortColumn.valueCouldBeUndefined || gridOptions && gridOptions.cellValueCouldBeUndefined || false;
const date1 = moment(value1, format, strict);
const date2 = moment(value2, format, strict);

if (value1 === null || value1 === '' || (checkForUndefinedValues && value1 === undefined) || !moment(value1, format, strict).isValid()) {
if (value1 === null || value1 === '' || (checkForUndefinedValues && value1 === undefined) || !date1.isValid()) {
diff = -1;
} else if (value2 === null || value2 === '' || (checkForUndefinedValues && value2 === undefined) || !moment(value2, format, strict).isValid()) {
} else if (value2 === null || value2 === '' || (checkForUndefinedValues && value2 === undefined) || !date2.isValid()) {
diff = 1;
} else {
const date1 = moment(value1, format, strict);
const date2 = moment(value2, format, strict);
diff = parseInt(date1.format('X'), 10) - parseInt(date2.format('X'), 10);
diff = date1.valueOf() < date2.valueOf() ? -1 : 1;
}

return sortDirection * (diff === 0 ? 0 : (diff > 0 ? 1 : -1));
return sortDirection * diff;
}

/** From a FieldType, return the associated date Sorter */
Expand Down