Skip to content

Commit

Permalink
Refactor more
Browse files Browse the repository at this point in the history
  • Loading branch information
khoidt committed Sep 22, 2023
1 parent c3fa9fb commit 2f4d3e9
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/fragmentarium/domain/DateConverterBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,33 @@ 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,
seMacedonianYear,
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
}
}

0 comments on commit 2f4d3e9

Please sign in to comment.