From: Thibaut Verron <thibaut.verron@gmail.com>
To: Heime <heimeborgia@protonmail.com>,
Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Re: Storing hours, minutes, seconds, and nanoseconds from format-time-string
Date: Tue, 6 Dec 2022 16:22:01 +0100 [thread overview]
Message-ID: <271ed048-4994-b9ac-1e29-e2d7042ab447@gmail.com> (raw)
In-Reply-To: <AS6FMVqpNJ2yj9y4QHcf3m5seWmFwltHxMcm66sf1LlF3Cq10WdliwPtIX5tJSC8ege9RhufG9f3wN36cAPJRj62-JPMT1rxTg1fzMYoA_w=@protonmail.com>
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
prev parent reply other threads:[~2022-12-06 15:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 9:23 Storing hours, minutes, seconds, and nanoseconds from format-time-string Heime
2022-12-06 10:19 ` Stephen Berman
2022-12-06 12:07 ` Heime
2022-12-06 12:14 ` Stephen Berman
2022-12-06 14:34 ` Emanuel Berg
2022-12-06 15:04 ` Thibaut Verron
2022-12-06 15:22 ` Thibaut Verron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=271ed048-4994-b9ac-1e29-e2d7042ab447@gmail.com \
--to=thibaut.verron@gmail.com \
--cc=heimeborgia@protonmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).