From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: random weekly event Date: Wed, 16 Jul 2014 00:13:23 +0200 Message-ID: <877g3e1da4.fsf@gmail.com> References: <877g3e9yzc.fsf@kanis.fr> <87bnsq1dyg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7Ayp-0007Za-Mk for emacs-orgmode@gnu.org; Tue, 15 Jul 2014 18:13:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7Ayh-0002yL-2o for emacs-orgmode@gnu.org; Tue, 15 Jul 2014 18:13:47 -0400 Received: from plane.gmane.org ([80.91.229.3]:54950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7Ayg-0002yH-SK for emacs-orgmode@gnu.org; Tue, 15 Jul 2014 18:13:38 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1X7Ayf-000240-0v for emacs-orgmode@gnu.org; Wed, 16 Jul 2014 00:13:37 +0200 Received: from g231111139.adsl.alicedsl.de ([92.231.111.139]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 16 Jul 2014 00:13:37 +0200 Received: from tjolitz by g231111139.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 16 Jul 2014 00:13:37 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Thorsten Jolitz writes: > Ivan Kanis 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