[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] random weekly event
From: |
Thorsten Jolitz |
Subject: |
Re: [O] random weekly event |
Date: |
Wed, 16 Jul 2014 00:13:23 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Thorsten Jolitz <address@hidden> writes:
> Ivan Kanis <address@hidden> 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