emacs org mode: how to remove the trailing dot in a mean of hms values

StackOverflow https://stackoverflow.com/questions/23510363

  •  16-07-2023
  •  | 
  •  

Вопрос

so i'm using vmean on a series of HMS values. because I don't care about fractions of seconds i convert the hms value to seconds, floor that value and then cast back to HMS. Which works fine, however, I have been unable to figure out how to remove the trailing dot from the seconds field.

what I have:

@II .. @III = (0@ 15' 36", 0@ 16' 7", 0@ 16' 36", 0@ 17' 05")

0@ 16' 21." = @7$4 = hms(0,0,floor(deg(vmean(@II..@III))*3600))

what I want:

0@ 16' 21" = @7$4 
Это было полезно?

Решение

Define a calc function that converts the seconds of an hms value to an integer:

(defmath hmsIntSecs (v)
  (let ((x v))
    (setq x (nreverse x))
    (setcar x (calcFunc-round (car x)))
    (setq x (nreverse x))
  )
)

Be sure to evaluate the function definition before proceeding.

What I get with just vmean:

| 0@ 16' 21." | 0@ 15' 36" | 0@ 16' 7" | 0@ 16' 36" | 0@ 17' 05" |
#+TBLFM: $1=vmean($2..$5)

Now what I get using hmsIntSecs:

| 0@ 16' 21" | 0@ 15' 36" | 0@ 16' 7" | 0@ 16' 36" | 0@ 17' 05" |
#+TBLFM: $1=hmsIntSecs(vmean($2..$5))
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top