Thorsten Jolitz <tjol...@gmail.com> writes: > Ivan Kanis <i...@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