emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] calculate weekday of birthday


From: Adam Porter
Subject: Re: [O] calculate weekday of birthday
Date: Mon, 31 Jul 2017 17:24:21 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hi Salome,

The decode-time function returns a list that includes the day-of-week as
a number from 0-6.  You'll have to give it an encoded time, which you
can use encode-time for.

A wild idea would be to use the shell "date" command, which is overkill
for this, but I just happen to have this code handy, in case you or
anyone else might find it useful:

#+BEGIN_SRC elisp
(defmacro call-process-with-args (process &rest args)
  "Return results of running PROCESS with ARGS."
  (declare (indent defun))
  `(with-temp-buffer
     (unless (= 0 (call-process ,process nil t nil
                                ,@args))
       (user-error ,(concat process " failed")))
     (buffer-substring-no-properties (point-min) (point-max))))

(defun get-day-of-week (string)
  "Parse STRING with the shell `date' command and return day-of-week as string."
  (call-process-with-args
   "date" "-d" string "+%a"))
#+END_SRC




reply via email to

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