Better HN
topnewbestaskshowjobs
Log inSign up

kipcole9

2 karma · joined Oct 2, 2023 (3y ago) · 3 submissions

Submissions

comment 3mo ago · link · parent

This "civic vs proleptic" split is a good use case for composite calendars: glue a few calendars together at their historical cut-over dates and the result behaves like one ordinary calendar.

I maintain an Elixir library (Calendrical) that does this. England, for example, is just three segments spliced onto a Julian base:

  defmodule England do
    use Calendrical.Composite,
      calendars: [
        ~D[1155-03-25 Calendrical.Julian.March25],  # year starts on Lady Day
        ~D[1751-03-25 Calendrical.Julian.Jan1],     # New Year moved to Jan 1
        ~D[1752-09-14 Calendrical.Gregorian]        # the 11-day jump
      ],
      base_calendar: Calendrical.Julian
  end
The "missing" days simply aren't valid dates, and stepping across the boundary jumps:

  England.days_in_month(1752, 9)              #=> 19
  England.valid_date?(1752, 9, 3)             #=> false
  Date.shift(~D[1752-09-02 England], day: 1)  #=> ~D[1752-09-14 England]

comment 2y ago · link · parent

> Lots of other tools are a bit short of the “first-class” level of polish; Image/Vix

I'm the author of Image and I'd welcome feedback on improving areas where you see lack of polish (there's a reason its not yet 1.0, but it is getting closer - primarily rewriting the color model).

Comments here are fine, or in the repo at https://github.com/kipcole9/image

comment 3y ago · link · parent

> The only modern language that gets it right is Swift:

Elixir too:

  Interactive Elixir (1.15.4) - press Ctrl+C to exit (type h() ENTER for help)
  iex(1)> String.length "ẇ͓̞͒͟͡ǫ̠̠̉̏͠͡ͅr̬̺͚̍͛̔͒͢d̠͎̗̳͇͆̋̊͂͐"
  4