From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: random weekly event
Date: Wed, 16 Jul 2014 00:13:23 +0200 [thread overview]
Message-ID: <877g3e1da4.fsf@gmail.com> (raw)
In-Reply-To: 87bnsq1dyg.fsf@gmail.com
Thorsten Jolitz <tjolitz@gmail.com> writes:
> Ivan Kanis <ivan@kanis.fr> writes:
>
> #+begin_src emacs-lisp
> (defun tj/return-random-timestamp-this-week ()
> "Insert random timestamp for this week."
> (interactive)
> (let* ((cal-info (decode-time (current-time)))
> (dow (nth 6 cal-info))
> (year (nth 5 cal-info))
> (month (nth 4 cal-info))
> (day (nth 3 cal-info))
> (hour (nth 2 cal-info))
> (random-day (+ day (1+ (random (- 5 dow)))))
> (random-hour (random 23))
> (random-minute (random 59))
> (random-second (random 59)))
> (format-time-string "%D %R"
> (encode-time random-second
> random-minute
> random-hour
> random-day
> month
> year))))
ups, should be probably rather this:
,----
| (random-day (+ day (1+ (random (- 7 dow)))))
`----
limit is not included, see
,----[ C-h f random RET ]
| random is a built-in function in `C source code'.
|
| (random &optional LIMIT)
|
| Return a pseudo-random number.
| All integers representable in Lisp, i.e. between `most-negative-fixnum'
| and `most-positive-fixnum', inclusive, are equally likely.
|
| With positive integer LIMIT, return random number in interval [0,LIMIT).
| With argument t, set the random number seed from the current time and pid.
| With a string argument, set the seed based on the string's contents.
| Other values of LIMIT are ignored.
|
| See Info node `(elisp)Random Numbers' for more details.
|
| [back]
`----
--
cheers,
Thorsten
next prev parent reply other threads:[~2014-07-15 22:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 19:57 random weekly event Ivan Kanis
2014-07-15 21:58 ` Thorsten Jolitz
2014-07-15 22:13 ` Thorsten Jolitz [this message]
2014-07-15 22:24 ` Thorsten Jolitz
2014-07-16 18:42 ` Ivan Kanis
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877g3e1da4.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=emacs-orgmode@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.