Skip to content
This repository was archived by the owner on Sep 27, 2023. 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
1 change: 1 addition & 0 deletions src/custom-functions/bcode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ test('isV3Call', () => {
expect(isV3Call('2020Q1', 'net_sales')).toBeTruthy()
expect(isV3Call('LYLQ', 'net_sales')).toBeTruthy()
expect(isV3Call('2020-09-06', 'market_capital')).toBeTruthy()
expect(isV3Call('latest', 'market_capital')).toBeTruthy()
})
5 changes: 4 additions & 1 deletion src/fiscal-periods/period-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ test('parse', () => {
expect(PeriodParser.parse('2020LQ')).toEqual(new YearQuarterParam(2020, LQ))
expect(PeriodParser.parse('LYQ3')).toEqual(new YearQuarterParam(LY, 3))
expect(PeriodParser.parse('LYLQ')).toEqual(new YearQuarterParam(LY, LQ))
expect(PeriodParser.parse('lylq')).toEqual(new YearQuarterParam(LY, LQ))
expect(PeriodParser.parse('LY-1Q4')).toEqual(new YearQuarterParam(new LyWithOffset(-1), 4))
expect(PeriodParser.parse('2020LQ-1')).toEqual(new YearQuarterParam(2020, new LqWithOffset(-1)))
expect(PeriodParser.parse('LY-1LQ-1')).toEqual(new YearQuarterParam(new LyWithOffset(-1), new LqWithOffset(-1)))
expect(PeriodParser.parse('ly-1lq-1')).toEqual(new YearQuarterParam(new LyWithOffset(-1), new LqWithOffset(-1)))
expect(PeriodParser.parse('2020-09-06')).toEqual(new DateParam(new Date('2020-09-06')))
expect(PeriodParser.parse('latest')).toEqual(new DateParam('latest'))
expect(PeriodParser.parse('Latest')).toEqual(new DateParam('latest'))
expect(() => PeriodParser.parse('foo')).toThrow(ParseError)
expect(() => PeriodParser.parse('2020/09/06')).toThrow(ParseError)
expect(() => PeriodParser.parse('latest')).toThrow(ParseError)
expect(() => PeriodParser.parse('0Q1')).toThrow(ParseError)
})
7 changes: 1 addition & 6 deletions src/fiscal-periods/period-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ export class PeriodParser {
}

static parse(str: string): DateParam | YearQuarterParam {
str = str.toUpperCase()

try {
return YearQuarterParam.parse(str)
} catch {
// noop
}

try {
const date = DateParam.parse(str)
if (!date.isLatest()) {
return date
}
return DateParam.parse(str)
} catch {
// noop
}
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = 'v12'
export const version = 'v13'