With apologies to mr womp womp
I had some time to examine the code of mine he was kind enough to look over and make more efficient. I realized that a bug had crept into it for years in the Julian calendar so I made a small correction to it.

While doing this I decided that it would make better sense to enter in the date as YYYY.MMDD rather then as the way I originally had it as MMDD.YYYY. This is because the algorithm allows you to enter both positive and negative years so entering -333.1024 for 24 Oct, -333 makes better sense then -1024.0333

Code:

ClrHome
Disp "ENTER DATE AS
Input "(YYYY.MMDD):",A
iPart(A→Y
iPart(1E2abs(A-Y)→M
1E2fPart(1E2abs(A-Y)→D
If M≤2:Then
Y-1→Y
M+12→M
End
If Y=1582 and M=10 and D>4 and D<15:4→D
0→A
If Y>1582 or (Y=1582 and M>10) or (Y=1582 and M=10 and D≥15):Then
int(sub(Y→A:2-A+int(A/4)→A:End
remainder(int(365.25(Y+4716))+int(30.6001(M+1))+D+A-1523,7
stbradley wrote:
With apologies to mr womp womp

Not sure why you're apologizing Laughing
I do this in the hopes that some tricks might stick and we can all write more efficient code in the end Wink
A lot of TI-Basic tricks I would strongly advise against in normal non-calculator programming. The parser is just so slow that nobody can afford to have slight inefficiencies, even if it means making the code less readable.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement