As per the title, I've made my own custom setDate/setTime menu in TI-Basic for a bit of fun. It's coded so that you can never enter an invalid date, and also is programmed for leap years. I should also mention that it's hard-coded to not allow a date before May 3 2021 (today), which can obviously be changed.

I know other people (such as LogicalJoe) have said they've created programs similar to this with their own features, but here's my take on it!



And here's the code:
Code:
ClrHome
augment(getDate,augment(getTime,{getTmFmt->L1
If Ans(1)+Ans(2)|E~2+Ans(3)|E~4<2021.0503
Then
   2021->L1(1
   5->L1(2
   3->L1(3
End
{31,28,31,30,31,30,31,31,30,31,30,31->L2
{12,0,0,0,24,~1,60,~1->L3
"JanFebMarAprMayJunJulAugSepOctNovDec->Str1
"L1(4)+12(L1(7)=12)(not(L1(4))-(12<L1(4->|v
Output(1,14,"press [clear]
Output(2,18,"to cancel
Output(1,1,"Set Date:
Output(3,3,toString(L1(3
Output(4,3,toString(L1(1
Output(5,1,"Set Time:
Output(6,3,toString(|v
Output(7,3,toString(L1(5
If 12=L1(7
Output(7,7,sub("AMPM",1+2(L1(4)>11),2
Output(8,1,"Set Time Format:
Output(9,3,toString(L1(7
Output(10,2,"SAVE
DelVar B2->A
2->I
Repeat K=45 or A>9 and sum(K={21,105
   If I<8
   L1(I->B
   If I=4
   |v->B
   1+(A>9->H
   "SAVE
   If I<8
   Then
      toString(B
      If I=2
      sub(Str1,3B-2,3
   End
   Output(A,2-(H=2),sub("<[",H,1)+Ans+sub(">]",H,1)+"
   Repeat Ans
      getKey
   End
   Ans->K
   If K=25 and A>2 or K=34 and A<=9
   Then
      Output(A,2-(A>9),"
      4-(A=2
      If A<=9 and A>2
      length(toString(B
      Output(A,3+Ans-(A>9),"
      Repeat Ans!=5 and Ans!=8
      A+(K=34)-(K=25->A
      End
      Ans-3(Ans=4)-2(Ans>5->I
   End
   If A<=9 and sum(K={24,26
   Then
      If I=3
      Then
         L2(L1(2
         If Ans=28
         Ans+not(fPart(L1(1)/4
         Ans->L3(3
      End
      L1(I)-(K=24)+(K=26
      If I=1
      min(2050,max(2021,Ans
      If I>1 and I<6
      Ans-(K-25)L3(2I-3)(Ans=L3(2I-2)+(K=26)(1+L3(2I-3
      If I=7
      12+12(12=L1(I
      Ans->L1(I
      If (I=4 or I=7) and 12=L1(7
      Then
         Output(7,7,sub("AMPM",1+2(L1(4)>11),2
         toString(L1(4)+12(not(L1(4))-(12<L1(4
         If I=7
         Output(6,3,Ans+"
      End
      If I=7 and 24=L1(7
      Then
         Output(7,7," 
         Output(6,3,toString(L1(4))+"
      End
      If L1(2)+L1(3)|E~2<5.03 and 2021=L1(1
      Then
         5+7(K=24 and I=2 and 5>L1(2->L1(2
         Output(2,3,sub(Str1,3Ans-2,3
         If L1(3)<3 and 5=L1(2
         Then
            3->L1(3
            L2(L1(2
            If Ans=28
            Ans+not(fPart(L1(1)/4
            If K=24 and I=3
            Ans->L1(3
         End
         Output(3,3,toString(L1(3))+"
      Else
         If I<=2
         Then
            L2(L1(2
            If Ans=28
            Ans+not(fPart(L1(1)/4
            If Ans<L1(3
            Then
               Output(3,3,Ans
               Ans->L1(3
            End
         End
      End
   End
End
If K!=45
Then
   setDate(L1(1),L1(2),L1(3
   setTime(L1(4),L1(5),0
   setTmFmt(L1(7
End
DelVar L1DelVar L2DelVar L3DelVar Str1DelVar |vClrHome


Feel free to try it out for yourself if you like. Also if you want to optimize/golf it be my guest! Currently sitting at 1384 bytes.

Of course, this program could be 0 bytes if you just use the OS's built in date/time editor... but that's no fun, is it?

Anyway, I hope you all like it.

Edit:
Thanks to LogicalJoe for coming up with a smaller and very clever way to create L2, so:

Code:
//this:
{31,28,31,30,31,30,31,31,30,31,30,31->L2

//becomes this:
0->rand
31-iPart(tanh^-1(fPart(10^(sinh(cosh(rand(12->L2
This is actually 11 bytes smaller than what I already have up in the top of the code, so yayay

Code:
augment(getTime,{getTmFmt->L1
getDate
If 2021.0503>sum(seq(Ans(I+1)/10^(2I),I,0,2    // 10^( token
{2021,5,3
augment(Ans,L1->L1
Michael2_3B wrote:
This is actually 11 bytes smaller than what I already have up in the top of the code, so yayay

Code:
augment(getTime,{getTmFmt->L1
getDate
If 2021.0503>sum(seq(Ans(I+1)/10^(2I),I,0,2    // 10^( token
{2021,5,3
augment(Ans,L1->L1

How about

Code:
getDate
If 2021.0503>sum(Ans10^(2-2cumSum(binomcdf(2,0
{2021,5,3
augment(Ans,augment(getTime,{getTmFmt->L1


EDIT: Here you go.

Code:
1->A
ClrHome
"JanFebMarAprMayJunJulAugSepOctNovDec->Str1
0->rand
31-int(tanh^-1(fPart(10^(sinh(cosh(rand(12->L2
getDate
If 2021.0503>sum(Ans10^(2-2cumSum(binomcdf(2,0
{2021,5,3
augment(DeltaList(cumSum(Ans)),{max(Ans
augment(Ans,getTime->L1
getTmFmt->T
Output(1,14,"press [clear]
Output(2,18,"to cancel
Output(1,1,"Set Date:
Output(5,1,"Set Time:
Output(8,1,"Set Time Format:
Repeat max(K={21,105,45
   sub(Str1,3L1(1)-2,3
   For(I,1,6
      If A=I
      "<"+Ans+">
      Output(iPart(cosh^-1(4^I)),3,Ans+" 
      {L1(2),max(L1),L1(4)-12(T=12 and L1(4)>12),L1(5),T,0
      toString(Ans(I
   End
   Output(7,7,sub("AMPM    ",1+2(L1(4)>11)+4(T=24),2
   "SAVE
   If A=7
   "["+Ans+"]
   Output(10,2,Ans+" 
   Repeat Ans
      getKey->K
   End
   A+(K=34 and A!=7)-(K=25 and A!=1->A
   If A<7
   Then
      L1(A)+(K=26)-(K=24
      If A=1
      Ans+12not(Ans)-12(Ans=13
      If A=2
      Then
         If Ans=(1+L2(L1(1
         1
         If not(Ans
         L2(L1(1
      End
      If A=3
      min(2050,max(2021,Ans
      If A=5
      Ans+59not(Ans)-59(Ans=60
      If A=4
      Ans-24(Ans=24)+24(Ans=~1
      Ans->L1(A
      If A=1
      min(L1(2),L2(Ans->L1(2
      If A=6 and 1=abs(K-25
      T-12(T/6-3->T
   End
End
If K!=45
Then
   setDate(L1(3),L1(1),L1(2
   setTime(L1(4),L1(5),0
   setTmFmt(T
End
DelVar Str1ClrList L1,L2
ClrHome

(About 600 bytes smaller)
  
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 GMT - 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