diff --git a/src/fragmentarium/domain/DateConverterBase.ts b/src/fragmentarium/domain/DateConverterBase.ts index 5b12d1982..3f76dc5b0 100644 --- a/src/fragmentarium/domain/DateConverterBase.ts +++ b/src/fragmentarium/domain/DateConverterBase.ts @@ -200,14 +200,11 @@ export default class DateConverterBase { private applySeleucidDate(props: CalendarUpdateProps): void { const { seBabylonianYear, mesopotamianMonth } = props - const seMacedonianYear = - seBabylonianYear > 0 && mesopotamianMonth < 7 - ? seBabylonianYear - : seBabylonianYear > -1 && mesopotamianMonth > 6 - ? seBabylonianYear + 1 - : undefined - const seArsacidYear = - seBabylonianYear >= 65 ? seBabylonianYear - 64 : undefined + const seMacedonianYear = this.calculateSeMacedonianYear( + seBabylonianYear, + mesopotamianMonth + ) + const seArsacidYear = this.calculateSeArsacidYear(seBabylonianYear) this.calendar = { ...this.calendar, seBabylonianYear, @@ -215,4 +212,21 @@ export default class DateConverterBase { seArsacidYear, } } + + private calculateSeMacedonianYear( + seBabylonianYear: number, + mesopotamianMonth: number + ): number | undefined { + if (seBabylonianYear > 0 && mesopotamianMonth < 7) { + return seBabylonianYear + } + if (seBabylonianYear > -1 && mesopotamianMonth > 6) { + return seBabylonianYear + 1 + } + return undefined + } + + private calculateSeArsacidYear(seBabylonianYear: number): number | undefined { + return seBabylonianYear >= 65 ? seBabylonianYear - 64 : undefined + } }