Created
June 19, 2024 09:06
-
-
Save 0racle/f398470f8045d946e7d3d022dee22f6e to your computer and use it in GitHub Desktop.
J translation of BQN datetime lib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cocurrent 'times' | |
dz_times_ =. 24 * *~ mz_times_ =. 60 | |
ot_times_ =. 719469 | |
dur_times_ =. ((100 * 365.25) - 0.75), 365.25, 30.6 | |
off_times_ =. (ot_times_ - 0.25), 0.75, 0.41 | |
T_times_ =. {{ | |
'day sec' =. (0, dz) #: y | |
time =. mz | <.@%&mz^:(|. i. 3) sec | |
cym =. 0$0 | |
for_z. dur ,"0 off do. | |
'zd zo' =. z | |
'dx mx' =. (0, zd) #: day + zo | |
day =. <. mx | |
cym =. cym, dx | |
end. | |
'cn yr mo' =. cym | |
mo =. mo - 12 * 10 <: mo | |
((100 * cn) + yr + mo < 0), (3 + mo), (1 + day), time | |
}} | |
F_times_ =. {{ | |
'yx mx dx' =. 3 {. x: y | |
f =. 0 > mx =. mx - 3 | |
z =. (dx - ot) + +/ <. (0,0, {: off) + dur * ((0,100) #: yx - f), mx + 12 * f | |
(dz * z) + (+~ mz&*)/ |. _3 {. y | |
}} | |
Now_z_ =: (6!:0) | |
ToTime_z_ =: T_times_ :. F_times_ | |
FromTime_z_ =: F_times_ :. T_times_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: