fix: fix quarter variables (#2648)
This commit is contained in:
		
							parent
							
								
									feaf4cd80a
								
							
						
					
					
						commit
						34b0ce06ba
					
				| @ -21,8 +21,11 @@ describe('parse date', () => { | |||||||
| 
 | 
 | ||||||
|   it('should parse quarter', async () => { |   it('should parse quarter', async () => { | ||||||
|     expectDate('2023Q1').toEqual(['2023-01-01T00:00:00.000Z', '2023-04-01T00:00:00.000Z']); |     expectDate('2023Q1').toEqual(['2023-01-01T00:00:00.000Z', '2023-04-01T00:00:00.000Z']); | ||||||
|  |     expectDate('2023Q2').toEqual(['2023-04-01T00:00:00.000Z', '2023-07-01T00:00:00.000Z']); | ||||||
|     expectDate('2023Q1+08:00').toEqual(['2022-12-31T16:00:00.000Z', '2023-03-31T16:00:00.000Z']); |     expectDate('2023Q1+08:00').toEqual(['2022-12-31T16:00:00.000Z', '2023-03-31T16:00:00.000Z']); | ||||||
|  |     expectDate('2023Q2+08:00').toEqual(['2023-03-31T16:00:00.000Z', '2023-06-30T16:00:00.000Z']); | ||||||
|     expectDate('2023Q1', { timezone: '+08:00' }).toEqual(['2022-12-31T16:00:00.000Z', '2023-03-31T16:00:00.000Z']); |     expectDate('2023Q1', { timezone: '+08:00' }).toEqual(['2022-12-31T16:00:00.000Z', '2023-03-31T16:00:00.000Z']); | ||||||
|  |     expectDate('2023Q2', { timezone: '+08:00' }).toEqual(['2023-03-31T16:00:00.000Z', '2023-06-30T16:00:00.000Z']); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('should parse iso week', async () => { |   it('should parse iso week', async () => { | ||||||
|  | |||||||
| @ -26,10 +26,11 @@ function parseYear(value) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function parseQuarter(value) { | function parseQuarter(value) { | ||||||
|   if (/^\d\d\d\d\Q\d$/.test(value)) { |   if (/^\d\d\d\dQ\d$/.test(value)) { | ||||||
|  |     const [year, q] = value.split('Q'); | ||||||
|     return { |     return { | ||||||
|       unit: 'quarter', |       unit: 'quarter', | ||||||
|       start: dayjs(value, 'YYYY[Q]Q').format('YYYY-MM-DD HH:mm:ss'), |       start: dayjs(year, 'YYYY').quarter(q).format('YYYY-MM-DD HH:mm:ss'), | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user