natashamoorfield / npm_calmarendian_date

GNU General Public License v3.0
0 stars 0 forks source link

Add a `CalmarendianDate.fromordinal` Method #17

Open natashamoorfield opened 2 years ago

natashamoorfield commented 2 years ago
classmethod CalmarendianDate.fromordinal(
    ordinal: int,
    day_ref_descriptor: DayRefDescriptor)

The default CalmarendianDate constructor is already an equivalent of the Gregorian date.fromordinal class method. Adding this explicit class method, however, not only allows better completeness of method equivalence, it also allows a single, dynamic "from ordinal" that can take either (any) type of ordinal date reference.

To maintain completeness, we shall also need to add an inverse method:

CalmarendianDate.toordinal(
    day_ref_descriptor: DayRefDescriptor = DayRefDescriptor.ADR
)