Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TellNewTime(a)
- {
- Time="";
- TV1=parseInt(TimeVariable[1]);
- TV2=parseInt(TimeVariable[2]);
- TV3=parseInt(TimeVariable[3]);
- A1=parseInt(a[0]);
- A2=parseInt(a[1]);
- A3=parseInt(a[2]);
- TA1=Math.floor(13-TV1);
- TA2=Math.floor(60-TV2);
- TA3=Math.floor(60-TV3);
- if(TimeVariable[0]=="+")
- {
- if(A3>=TA3)
- {
- A3sub1=Math.floor(A3+TV3);
- A3FT=Math.floor(A3sub1-60);
- if(A2>=Math.floor(TA2-1))
- {
- A2sub1=Math.floor(A2+TV2+1);
- A2FT=Math.floor(A2sub1-60);
- if(A1>=Math.floor(TA1-1))
- {
- A1sub1=Math.floor(A1+TV1+1);
- A1FT=Math.floor(A1sub1-12);
- if(a[3]=="am")
- {
- AP="pm"
- }
- else
- {
- AP="am"
- }
- }
- else
- {
- A1FT=Math.floor(A1+TV1+1);
- AP=a[3]
- }
- }
- else
- {
- A2FT=Math.floor(A2+TV2+1);
- if(A1>=TA1)
- {
- A1sub1=Math.floor(A1+TV1);
- A1FT=Math.floor(A1sub1-12);
- if(a[3]=="am")
- {
- AP="pm"
- }
- else
- {
- AP="am"
- }
- }
- else
- {
- A1FT=Math.floor(A1+TV1);
- AP=a[3]
- }
- }
- }
- else
- {
- A3FT=Math.floor(A3+TV3);
- if(A2>=TA2)
- {
- A2sub1=Math.floor(A2+TV2);
- A2FT=Math.floor(A2sub1-60);
- if(A1>=Math.floor(TA1-1))
- {
- A1sub1=Math.floor(A1+TV1+1);
- A1FT=Math.floor(A1sub1-12);
- if(a[3]=="am")
- {
- AP="pm"
- }
- else
- {
- AP="am"
- }
- }
- else
- {
- A1FT=Math.floor(A1+TV1+1);
- AP=a[3]
- }
- }
- else
- {
- A2FT=Math.floor(A2+TV2);
- if(A1>=TA1)
- {
- A1sub1=Math.floor(A1+TV1);
- A1FT=Math.floor(A1sub1-12);
- if(a[3]=="am")
- {
- AP="pm"
- }
- else
- {
- AP="am"
- }
- }
- else
- {
- A1FT=Math.floor(A1+TV1);
- AP=a[3]
- }
- }
- }
- }
- else
- {
- if(A3<TV3)
- {
- A3sub1=Math.floor(A3-TV3);
- A3FT=Math.floor(A3sub1+60);
- if(A2<Math.floor(TV2+1))
- {
- A2sub1=Math.floor(A2-TV2-1);
- A2FT=Math.floor(A2sub1+60);
- if(A1<Math.floor(TV1+1))
- {
- A1sub1=Math.floor(A1-TV1-1);
- A1FT=Math.floor(A1sub1+12);
- if(a[3]=="am")
- {
- AP="pm"
- }
- else
- {
- AP="am"
- }
- }
- else
- {
- A1FT=Math.floor(A1-TV1-1);
- AP=a[3]
- }
- }
- else
- {
- A2FT=Math.floor(A2-TV2-1);
- if(A1<TV1)
- {
- A1sub1=Math.floor(A1-TV1);
- A1FT=Math.floor(A1sub1+12);
- if(a[3]=="am")
- {
- AP="pm"
- }
- else
- {
- AP="am"
- }
- }
- else
- {
- A1FT=Math.floor(A1-TV1);
- AP=a[3]
- }
- }
- }
- else
- {
- A3FT=Math.floor(A3-TV3);
- if(A2<TV2)
- {
- A2sub1=Math.floor(A2-TV2);
- A2FT=Math.floor(A2sub1+60);
- if(A1<Math.floor(TV1+1))
- {
- A1sub1=Math.floor(A1-TV1-1);
- A1FT=Math.floor(A1sub1+12);
- if(a[3]=="am")
- {
- AP="pm"
- }
- else
- {
- AP="am"
- }
- }
- else
- {
- A1FT=Math.floor(A1-TV1-1);
- AP=a[3]
- }
- }
- else
- {
- A2FT=Math.floor(A2-TV2);
- if(A1<TV1)
- {
- A1sub1=Math.floor(A1-TV1);
- A1FT=Math.floor(A1sub1+12);
- if(a[3]=="am")
- {
- AP="pm"
- }
- else
- {
- AP="am"
- }
- }
- else
- {
- A1FT=Math.floor(A1-TV1);
- AP=a[3]
- }
- }
- }
- };
- if(A2FT<10)
- {
- A2FTZ="0"+A2FT
- }
- else
- {
- A2FTZ=A2FT
- };
- if(A3FT<10)
- {
- A3FTZ="0"+A3FT
- }
- else
- {
- A3FTZ=A3FT
- };
- if(TimeVariable[4].toLowerCase()=="yes")
- {
- Time+=A1FT+":"+A2FTZ+":"+A3FTZ+" "+AP
- }
- else
- {
- Time+=A1FT+":"+A2FTZ+" "+AP
- };
- if(TimeVariable[4].toLowerCase()!="yes"&&TimeVariable[4].toLowerCase()!="no")
- {
- Time="Please only use Yes or No for whether or not you want seconds in the fifth field"
- };
- if(TimeVariable[0]!="+"&&TimeVariable[0]!="-")
- {
- Time="Please only use a + or - symbol in the first field"
- };
- if(TV3<0)
- {
- Time="Please only add or subtract seconds in 0-59"
- };
- if(TV2<0)
- {
- Time="Please only add or subtract minutes in 0-59"
- };
- if(TV1<0)
- {
- Time="Please only add or subtract hours in 0-12"
- };
- if(TV3>59)
- {
- Time="Please only add or subtract seconds in 0-59"
- };
- if(TV2>59)
- {
- Time="Please only add or subtract minutes in 0-59"
- };
- if(TV1>12)
- {
- Time="Please only add or subtract hours in 0-12"
- };
- return Time
- };
- TellNewTime(a)
Add Comment
Please, Sign In to add comment