CameronFitzy

Time

Aug 18th, 2020 (edited)
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function TellNewTime(a)
  2. {
  3. Time="";
  4. TV1=parseInt(TimeVariable[1]);
  5. TV2=parseInt(TimeVariable[2]);
  6. TV3=parseInt(TimeVariable[3]);
  7.  
  8. A1=parseInt(a[0]);
  9. A2=parseInt(a[1]);
  10. A3=parseInt(a[2]);
  11.  
  12. TA1=Math.floor(13-TV1);
  13. TA2=Math.floor(60-TV2);
  14. TA3=Math.floor(60-TV3);
  15.  
  16. if(TimeVariable[0]=="+")
  17. {
  18. if(A3>=TA3)
  19. {
  20. A3sub1=Math.floor(A3+TV3);
  21. A3FT=Math.floor(A3sub1-60);
  22. if(A2>=Math.floor(TA2-1))
  23. {
  24. A2sub1=Math.floor(A2+TV2+1);
  25. A2FT=Math.floor(A2sub1-60);
  26. if(A1>=Math.floor(TA1-1))
  27. {
  28. A1sub1=Math.floor(A1+TV1+1);
  29. A1FT=Math.floor(A1sub1-12);
  30. if(a[3]=="am")
  31. {
  32. AP="pm"
  33. }
  34. else
  35. {
  36. AP="am"
  37. }
  38. }
  39. else
  40. {
  41. A1FT=Math.floor(A1+TV1+1);
  42. AP=a[3]
  43. }
  44. }
  45. else
  46. {
  47. A2FT=Math.floor(A2+TV2+1);
  48. if(A1>=TA1)
  49. {
  50. A1sub1=Math.floor(A1+TV1);
  51. A1FT=Math.floor(A1sub1-12);
  52. if(a[3]=="am")
  53. {
  54. AP="pm"
  55. }
  56. else
  57. {
  58. AP="am"
  59. }
  60. }
  61. else
  62. {
  63. A1FT=Math.floor(A1+TV1);
  64. AP=a[3]
  65. }
  66. }
  67. }
  68. else
  69. {
  70. A3FT=Math.floor(A3+TV3);
  71. if(A2>=TA2)
  72. {
  73. A2sub1=Math.floor(A2+TV2);
  74. A2FT=Math.floor(A2sub1-60);
  75. if(A1>=Math.floor(TA1-1))
  76. {
  77. A1sub1=Math.floor(A1+TV1+1);
  78. A1FT=Math.floor(A1sub1-12);
  79. if(a[3]=="am")
  80. {
  81. AP="pm"
  82. }
  83. else
  84. {
  85. AP="am"
  86. }
  87. }
  88. else
  89. {
  90. A1FT=Math.floor(A1+TV1+1);
  91. AP=a[3]
  92. }
  93. }
  94. else
  95. {
  96. A2FT=Math.floor(A2+TV2);
  97. if(A1>=TA1)
  98. {
  99. A1sub1=Math.floor(A1+TV1);
  100. A1FT=Math.floor(A1sub1-12);
  101. if(a[3]=="am")
  102. {
  103. AP="pm"
  104. }
  105. else
  106. {
  107. AP="am"
  108. }
  109. }
  110. else
  111. {
  112. A1FT=Math.floor(A1+TV1);
  113. AP=a[3]
  114. }
  115. }
  116. }
  117. }
  118. else
  119. {
  120. if(A3<TV3)
  121. {
  122. A3sub1=Math.floor(A3-TV3);
  123. A3FT=Math.floor(A3sub1+60);
  124. if(A2<Math.floor(TV2+1))
  125. {
  126. A2sub1=Math.floor(A2-TV2-1);
  127. A2FT=Math.floor(A2sub1+60);
  128. if(A1<Math.floor(TV1+1))
  129. {
  130. A1sub1=Math.floor(A1-TV1-1);
  131. A1FT=Math.floor(A1sub1+12);
  132. if(a[3]=="am")
  133. {
  134. AP="pm"
  135. }
  136. else
  137. {
  138. AP="am"
  139. }
  140. }
  141. else
  142. {
  143. A1FT=Math.floor(A1-TV1-1);
  144. AP=a[3]
  145. }
  146. }
  147. else
  148. {
  149. A2FT=Math.floor(A2-TV2-1);
  150. if(A1<TV1)
  151. {
  152. A1sub1=Math.floor(A1-TV1);
  153. A1FT=Math.floor(A1sub1+12);
  154. if(a[3]=="am")
  155. {
  156. AP="pm"
  157. }
  158. else
  159. {
  160. AP="am"
  161. }
  162. }
  163. else
  164. {
  165. A1FT=Math.floor(A1-TV1);
  166. AP=a[3]
  167. }
  168. }
  169. }
  170. else
  171. {
  172. A3FT=Math.floor(A3-TV3);
  173. if(A2<TV2)
  174. {
  175. A2sub1=Math.floor(A2-TV2);
  176. A2FT=Math.floor(A2sub1+60);
  177. if(A1<Math.floor(TV1+1))
  178. {
  179. A1sub1=Math.floor(A1-TV1-1);
  180. A1FT=Math.floor(A1sub1+12);
  181. if(a[3]=="am")
  182. {
  183. AP="pm"
  184. }
  185. else
  186. {
  187. AP="am"
  188. }
  189. }
  190. else
  191. {
  192. A1FT=Math.floor(A1-TV1-1);
  193. AP=a[3]
  194. }
  195. }
  196. else
  197. {
  198. A2FT=Math.floor(A2-TV2);
  199. if(A1<TV1)
  200. {
  201. A1sub1=Math.floor(A1-TV1);
  202. A1FT=Math.floor(A1sub1+12);
  203. if(a[3]=="am")
  204. {
  205. AP="pm"
  206. }
  207. else
  208. {
  209. AP="am"
  210. }
  211. }
  212. else
  213. {
  214. A1FT=Math.floor(A1-TV1);
  215. AP=a[3]
  216. }
  217. }
  218. }
  219. };
  220.  
  221. if(A2FT<10)
  222. {
  223. A2FTZ="0"+A2FT
  224. }
  225. else
  226. {
  227. A2FTZ=A2FT
  228. };
  229. if(A3FT<10)
  230. {
  231. A3FTZ="0"+A3FT
  232. }
  233. else
  234. {
  235. A3FTZ=A3FT
  236. };
  237.  
  238. if(TimeVariable[4].toLowerCase()=="yes")
  239. {
  240. Time+=A1FT+":"+A2FTZ+":"+A3FTZ+" "+AP
  241. }
  242. else
  243. {
  244. Time+=A1FT+":"+A2FTZ+" "+AP
  245. };
  246.  
  247. if(TimeVariable[4].toLowerCase()!="yes"&&TimeVariable[4].toLowerCase()!="no")
  248. {
  249. Time="Please only use Yes or No for whether or not you want seconds in the fifth field"
  250. };
  251.  
  252. if(TimeVariable[0]!="+"&&TimeVariable[0]!="-")
  253. {
  254. Time="Please only use a + or - symbol in the first field"
  255. };
  256.  
  257. if(TV3<0)
  258. {
  259. Time="Please only add or subtract seconds in 0-59"
  260. };
  261. if(TV2<0)
  262. {
  263. Time="Please only add or subtract minutes in 0-59"
  264. };
  265. if(TV1<0)
  266. {
  267. Time="Please only add or subtract hours in 0-12"
  268. };
  269.  
  270. if(TV3>59)
  271. {
  272. Time="Please only add or subtract seconds in 0-59"
  273. };
  274. if(TV2>59)
  275. {
  276. Time="Please only add or subtract minutes in 0-59"
  277. };
  278. if(TV1>12)
  279. {
  280. Time="Please only add or subtract hours in 0-12"
  281. };
  282.  
  283. return Time
  284. };
  285.  
  286. TellNewTime(a)
Add Comment
Please, Sign In to add comment