Skip to content

Improve efficiency of date add/until #7077

@sffc

Description

@sffc

The specification algorithm is designed to be readable, but it is not fast, because it adds one month and one year at a time. There are two cases that can be optimized:

  1. Adding 1000 months to a date requires running a loop for each year, and adding the number of days in each year until the month is in-range. For calendars with a fixed number of months per year, this is trivial to fast-path. For calendars with a variable number of months per year, this can likely still be fast-pathed, but more care needs to be taken.
  2. Adding 1000 days to a date requires running a loop for each month, and adding the number of days in each month until the day is in-range. No calendar has a fixed number of days per month. But, a fast-path could be to add a years-worth of days all at once, and then to add multiple years at once, being careful about leap years, of course.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions