dms calculations

dsnz

Well-known member
does anyone know a trick to do easily dms calculations ?

eg. if time elapsed in seconds is 5000

then

dms_d(5000) = 1
dms_m(5000) = 23
dms_s(5000) = 20

so 5000 sec = 1 hr 23 min 20 sec (1:23:20)

the same for the inverse operation
 

Dm114

Well-known member
does anyone know a trick to do easily dms calculations ?

eg. if time elapsed in seconds is 5000

then

dms_d(5000) = 1
dms_m(5000) = 23
dms_s(5000) = 20

so 5000 sec = 1 hr 23 min 20 sec (1:23:20)

the same for the inverse operation
All integer variables:
elapsed_s=5000
dms_d=floor(elapsed_s/3600)
dms_m=floor((elapsed_s-(dms_d*3600))/60)
dms_s=elapsed_s-(dms_h*3600)-(dms_m*60)
 

Dm114

Well-known member
does anyone know a trick to do easily dms calculations ?

eg. if time elapsed in seconds is 5000

then

dms_d(5000) = 1
dms_m(5000) = 23
dms_s(5000) = 20

so 5000 sec = 1 hr 23 min 20 sec (1:23:20)

the same for the inverse operation
elapsed_s=(dms_h*3600)+(dms_m*60)+dms_s
 

FrameXX

Well-known member
does anyone know a trick to do easily dms calculations ?

eg. if time elapsed in seconds is 5000

then

dms_d(5000) = 1
dms_m(5000) = 23
dms_s(5000) = 20

so 5000 sec = 1 hr 23 min 20 sec (1:23:20)

the same for the inverse operation

Inverse operation could be easy if you have hours minutes and seconds saved in separated variables.

Set Variable seconds: ([hour]*3600)+([minute]*60)+[seconds];

But the other way (from seconds to normal time) is pain, at least for me but it seems @Dm114 knows how to do that one.

EDIT

Ok, so I found an alternative to what dm114 proposes (but it's propably the same thing, with just another look). You just need to fill seconds variable and run the actions.

(Files attached)
 

Attachments

  • Seconds_converter.macro
    3 KB · Views: 9
  • Seconds_converter.png
    Seconds_converter.png
    41.2 KB · Views: 18
Last edited:

dsnz

Well-known member
well I hoped for something still simpler (some operation that as a side effect produces the dms values even as a single string dd:mm:ss),

I will probably make a dms macro as a kind of procedure with standard named global variables

thanks all
 

FrameXX

Well-known member
well I hoped for something still simpler (some operation that as a side effect produces the dms values even as a single string dd:mm:ss),

I will probably make a dms macro as a kind of procedure with standard named global variables

thanks all

I edited my comment and added something new.

And also? What shortcut dms means?
 

Dm114

Well-known member
well I hoped for something still simpler (some operation that as a side effect produces the dms values even as a single string dd:mm:ss),

I will probably make a dms macro as a kind of procedure with standard named global variables

thanks all
You are right. You can create a kind of function with 'dms...' variables as global ones instead of local ones and call (run) this macro with 'Wait to complete before running...' option checked every time you need to convert an elapsed time.

I use this trick to accomplish some functions I gathered in a category I called 'Functions' and it works very well.
 
Top