TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: civil.eng on May 25, 2023, 06:18:45 AM
-
Hello everyone,
I need a function to add two times together, For example I have current time with this format :
"13:20:59"
Now, I want to add a given time to current time like this : "00:11:12"
To put it simply, the function should add minutes and seconds to current time. the given time includes just minutes and seconds. With this example the result time is :
"13:32:11"
-
Not sure, perhaps this would work, but untested...
(defun c:addtime ( / add curr secs newt )
(setq curr (getpoint "\nEnter current time in format hh,mm,ss : "))
(setq add (getpoint "\nEnter additional time in format hh,mm,ss : "))
(setq secs (+ (caddr add) (* 60 (cadr add)) (* 3600 (car add))))
(setq newt (+ (caddr curr) (* 60 (cadr curr)) (* 3600 (car curr)) secs))
(setq newt (list (rem (fix (/ newt 3600.0)) 24) (fix (/ (- newt (* 3600.0 (fix (/ newt 3600.0)))) 60.0)) (fix (- newt (+ (* 60.0 (fix (/ (- newt (* 3600.0 (fix (/ newt 3600.0)))) 60.0))) (* 3600.0 (fix (/ newt 3600.0))))))))
)
Enter current time in format hh,mm,ss : 13,20,59
Enter additional time in format hh,mm,ss : 00,11,12
(13 32 11)
HTH.
M.R.
-
Why GetPoint ?
-
Why GetPoint ?
three real numbers at once?
-
An oldy from the HP calculator days DDD.MMSS. this was for survey bearing its a number so easy to pull apart, HR.MMSS as number.
But I like Ribarm method.