⍝ Days since 1899-12-31 00:00:00:

    days 1935 1 8                       ⍝ Whole number of days.
12791

    days 1935 1 8, 12 20                ⍝ Part way through day.
12791.51389

    days 1879 3 14 11 30                ⍝ Negative for dates before 1899 12 31.
¯7596.520833

    days 2 3⍴1533 8 26, 1536 5 19       ⍝ Matrix of dates → vector of day nos.
¯133796 ¯132799

    --/days↑1752 09∘,¨02 14             ⍝ Sept 1752: 2 and 14 contiguous in GB.
1
    days↑1700,¨(2 28)(2 29)(3 1)        ⍝ 1700 _was_ a leap year in GB.
¯72979 ¯72978 ¯72977

    {⍵≡date days ⍵} ⎕ts                 ⍝ full circle.
1
    ⍝ Peter Michael's neat one-liners:

    n_days←{{¯693896+(⍵>730500)+⌊36524×⍵÷36525}¯60++/⍵[2]↑(⌈365.25⊥⍵[1 3]),31,(29-×4|1⊃⍵),9⍴5⍴31 30}
    n_date←{y,m,1+d-(m←m+.≤d)⊃m←+\0 31,(29-×4|1⊃y d←⌊0 365.25⊤694035+⌊(36525×⍵-60.5+0.5××⍵-36584)÷36524),9⍴5⍴31 30}
    
    {⍵≡n_date n_days ⍵} 3↑⎕ts           ⍝ full circle.
1
    {(n_days¨↓⍵),(days ⍵),⍵}2 3⍴ 2400 2 29 2400 3 1     ⍝ Leap year 2400.
182681 182681 2400 2 29
182681 182682 2400 3  1

    eudays←15821004∘days                ⍝ European Gregorian calendar reform.

    eudays ↑1582 10∘,¨04 15             ⍝ Oct 1582: 4th and 15th contiguous.
¯115860 ¯115859

    --/eudays ↑1700∘,¨(2 28)(3 1)       ⍝ 1700 was not a leap year in Europe.
1

    Alpha ##.test'Dates'                ⍝ test for both days and dates.

Back to: code

Back to: Workspaces