help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Storing hours, minutes, seconds, and nanoseconds from format-time-st


From: Thibaut Verron
Subject: Re: Storing hours, minutes, seconds, and nanoseconds from format-time-string
Date: Tue, 6 Dec 2022 16:22:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2

On 06/12/2022 10:23, Heime wrote:

I am getting the time using the format "%FT%T.%N%z".

(format-time-string "%FT%T.%N%z" nil tzone)

 From the result I need to get the hours, minutes, seconds,
and nanoseconds to store them into four numeric variables.

How can I do this from the output of "format-time-string".

Dear Heime,

As others have already pointed out, you might benefit by reading up on the etiquette rules applicable when asking strangers for help on the internet.

Things like saying please and thank you, showing minimal effort, expressing the problem clearly... would go a long way in improving the form of your communication, and in turn in getting better and faster answers.

This community is very friendly and most cannot say no to an elisp problem, but nobody has unlimited patience.

---

You can use format-time-string to directly get the data you want, and then separate it either by using string processing, or by making the output a valid elisp sexp.

For example:

(split-string (format-time-string "%H %M %S %N")) ;; using string processing

(car (read-from-string (format-time-string "(%H %M %S %N)"))) ;; using elisp processing


Good luck.

Thibaut






reply via email to

[Prev in Thread] Current Thread [Next in Thread]