Fix: handle very old dates with positive offset too (#8335)

This commit is contained in:
shamoon 2024-11-22 08:39:51 -08:00 committed by GitHub
parent 447b4cdb98
commit be684c9a11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -77,14 +77,19 @@ describe('CorrespondentListComponent', () => {
it('should support very old date strings', () => { it('should support very old date strings', () => {
jest.spyOn(correspondentsService, 'listFiltered').mockReturnValue( jest.spyOn(correspondentsService, 'listFiltered').mockReturnValue(
of({ of({
count: 1, count: 2,
all: [1], all: [1, 2],
results: [ results: [
{ {
id: 1, id: 1,
name: 'Correspondent1', name: 'Correspondent1',
last_correspondence: '1832-12-31T15:32:54-07:52:58', last_correspondence: '1832-12-31T15:32:54-07:52:58',
}, },
{
id: 2,
name: 'Correspondent2',
last_correspondence: '1901-07-01T00:00:00+00:09:21',
},
], ],
}) })
) )

View File

@ -52,7 +52,7 @@ export class CorrespondentListComponent extends ManagementListComponent<Correspo
date = new Date( date = new Date(
c.last_correspondence c.last_correspondence
?.toString() ?.toString()
.replace(/-(\d\d):\d\d:\d\d/gm, `-$1:00`) .replace(/([-+])(\d\d):\d\d:\d\d/gm, `$1$2:00`)
) )
} }
return this.datePipe.transform(date) return this.datePipe.transform(date)