Quotition Jottings
Vector 1:3, page 156
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 156
Part 1 — The “TICTOCTI” — an unfamiliar subdivision of a minute¶
While browsing through an obscure anthropological journal the other day I chanced upon the following entry:
‘Professor Julian Day and Dr. Sid E Real (who recently reported from a distant South Pacific island that the natives have 255 different words for COCONUT) have made another startling discovery. In this remote corner of the world the passage of time is measured in hours, minutes and TICTOCTIs. What precisely is a TICTOCTI?
1 TICTOCTI = 1⅓ TICTOCs = 1.3333… seconds
‘The unfamiliar subdivision of a minute is said to be more in keeping with the pace of life on those sun-drenched coral shores. “Our discovery is of great significance to theologians, philosophers and manufacturers of multi-function digital wrist-watches” the Professor said.’
Having learned of these resourceful and free-thinking islanders I immediately resolved to adopt their curious unit for my ‘business micro’ projects. As a measure of elapsed time of day it proved to be ideal. The number of TICTOCTIs in 24 hours is 64800 which by happy coincidence is somewhat less than 2 to the power of 16. Thus any instant in a 24 hour period may be conveniently represented as a 2-byte integer by conversion to TICTOCTI units.
The method is straightforward. To pack HH-MM-SS into TICTOCTI units:
Note the 2*15 offset which keeps the number within the 2-byte limit.
To unpack TICTOCTI units back to HH-MM-SS
Experiment confirms the hunch that the method is ‘spot on’ to the nearest second for 75% of the time and only ‘one second out’ for the other 25%.
If your APL does not feature 2-byte integers (or your auditors insist on timestamps recorded to the nearest millisecond) then you may find the TICTOCTI a little academic (like the Professor). But for some micro-bound APLers the anthropologists’ serendipitous discovery introduces an efficient way to store the time of day, or to put it another way, save space when you save time.
Here are the functions for doing the conversions:
∇ R←TIMP A
[1] ⍝ Pack 3-column HH-MM-SS timestamp into 2-byte TICTOCTI units
[2] ⍝ N.B. 1 TICTOCTI = 1.33333.....secs.
[3] R←¯32768+⌊0.75× 24 60 60 ⊥⍉A
∇
∇ R←TIMU A
[1] ⍝ Unpack 2-byte TICTOCTI units into 3-column HH-MM-SS timestamp
[2] ⍝ N.B. 1 TICTOCTI = 1.33333.....secs.
[3] R←⍉ 24 60 60 ⊤1+⌊(32768+A)÷0.75
∇
Examples:
+A←TIMP 2 3⍴0 0 1,23 59 59
¯32768 32031
TIMU A
0 0 1
23 59 59
+A←TIMP 1 3⍴3↓⎕TS
13380
TIMU A
17 5 31
,0 2↓TIMU TIMP 0,0,25 1⍴⍳25
1 2 3 5 5 6 7 9 9 10 11 13 13 14 15 17 17 18 19 21 21 22 23 25 25
Part 2 — DDMYY — the cult of the negative month number¶
Professor Julian Day’s disclosure of chronological unorthodoxy in the South Pacific does not end with the ‘tictocti’ unit. The islanders are pioneers of the NEGATIVE MONTH NUMBER.
Let me lessen the blow by arguing that the assignment of integers 1 to 12 for the set of twelve months January to December is only one dull choice out of a rich set of possibilities. For example:
- The Mathematician’s Delight. Proponents of index origin zero might favour the series 0 to 11. This would be consistent with a culture which calls the second level of a building the first floor. Ergo JAN = 0.
-
The Historical Perspective. Is this not reasonable:
SEPT, OCTO, NOVE, DECE = 7, 8, 9,10
If December is the tenth month (it was once!) then surely JAN = -1. - The Taxman’s Rationale. The Inland Revenue gets down to business in the second quarter of the year. Foolish New Year celebrations take place on April 1st. In this case JAN = -2.
Why our South Sea Islanders should favour the approach of the Inland Revenue must be one of the great mysteries of our time. Unfortunately Prof. Julian Day throws no light on this, but his article (appearing in the latest University of Nether Wallop Bulletin) does supply the following table:
| JAN | -2 |
| FEB | -1 |
| MAR | 0 |
| APR | 1 |
| MAY | 2 |
| JUN | 3 |
| JUL | 4 |
| AUG | 5 |
| SEP | 6 |
| OCT | 7 |
| NOV | 8 |
| DEC | 9 |
Did you know that APL2 has a time zone feature quadTZ which can be used to fiddle with the hours of quadTS? Our Antipodean friends have been fiddling with the months as well!
Their format takes some getting used to. Whereas Europeans favour:
DDMMYY
and Americans go for:
MMDDYY
The natives of our South Pacific island insist upon:
DDMYY (SIGNED!)
By another happy (and unbelievable) coincidence, all dates between 1950 and 2049 written in this unconventional format lie within the range -32768 to 32767. The South Pacific fiscal year leads to a practical way of packing a date into a 2-byte integer.
Here are the functions with some examples (bearing in mind that in that far off island years are counted from 1950 — the date they gained independence):
∇ R←DATP A
[1] ⍝ Pack 3-column YY-MM-DD dates in <A> into 2-byte format
[2] R←A-((1↑⍴A),3)⍴ 0 3 1950
[3] R←(1-2×0>R[;2])×+/(|R)×(⍴R)⍴ 1000 100 1
∇
∇ R←DATU A;MM
[1] ⍝ Unpack 2-byte dates in <A> into 3-column YY-MM-DD format
[2] R←|A ⋄ MM←3+(×A)×10|⌊R÷100
[3] R←(⌊R÷1000),MM,[1.5]1950+100|R
∇
DATP 2 3⍴1 1 1950 , 31 12 2049
¯1200 31999
⍝ The Frisbee introduced by Wham-O Manufacturing Co.:
DATP 1 3⍴13 1 1957 ⍝ 13th January, 1957
¯13207
⍝ Boy Scouts permitted to wear long trousers:
DATP 1 3⍴1 11 1961 ⍝ 1st November, 1961
1811
⍝ Women win the right to vote in Switzerland:
DATP 1 3⍴7 2 1971 ⍝ 7th February, 1971
¯7121
⍝ Create some test data:
DMY←⌽(1949+?1000⍴100),(?1000⍴12),[1.5]?1000⍴28
⍝ Check that functions work:
∧/,DMY=DATU DATP DMY
1
⍝ Compare with APL*plus/PC supplied functions
⍝ from workspace <1 DATES> :
∧/,DMY=⌽DATEREP DATEBASE⌽DMY
1
⍝ Timings show that <DATP> and <DATU> are almost 3 and 4
⍝ times faster than <DATEBASE> and <DATEREP>, respectively,
⍝ using APL*plus/PC release 3.1 on an IBM PC with an 8087
⍝ maths co-processor installed.
If YYMMDD is unattractive in APL*Plus/PC what is wrong with a day number solution? Day numbers are excellent for sorting, date-differencing, days of the week etc. But conversion to and fro is quite complex and therefore slow. The ‘taxman’s date’ described above is 4 times quicker to unpack than a day-number to date conversion. Which prompts the question: Are day numbers’ days numbered?