From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Cave Subject: Python script to generate a daily diary/journal Date: Fri, 26 Jun 2009 03:32:37 +0000 (UTC) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MK2BP-0006qL-Ea for emacs-orgmode@gnu.org; Thu, 25 Jun 2009 23:32:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MK2BK-0006pG-Ne for emacs-orgmode@gnu.org; Thu, 25 Jun 2009 23:32:58 -0400 Received: from [199.232.76.173] (port=57641 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MK2BK-0006p6-KS for emacs-orgmode@gnu.org; Thu, 25 Jun 2009 23:32:54 -0400 Received: from main.gmane.org ([80.91.229.2]:52199 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MK2BK-0004De-4M for emacs-orgmode@gnu.org; Thu, 25 Jun 2009 23:32:54 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MK2BE-0006IU-6c for emacs-orgmode@gnu.org; Fri, 26 Jun 2009 03:32:48 +0000 Received: from 203.166.111.206 ([203.166.111.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 26 Jun 2009 03:32:48 +0000 Received: from charles_cave by 203.166.111.206 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 26 Jun 2009 03:32:48 +0000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I wanted to create the equivalent of a yearly diary with space for recording notes on each day. I used to use paper diaries with the week number and day number written on each page. I already have a system using Remember to record notes with date/time stamps but this script generates a file with a specific structure. First of all, here is part of the output * July 2009 ** Wed [2009-07-01 Wed] Week 27 - Day 182 ** Thu [2009-07-02 Thu] Week 27 - Day 183 ** Fri [2009-07-03 Fri] Week 27 - Day 184 ** Sat [2009-07-04 Sat] Week 27 - Day 185 ** Sun [2009-07-05 Sun] Week 27 - Day 186 ** Week 28 - Mon [2009-07-06 Mon] Week 28 - Day 187 Some useful features of this format: 1. Clicking on a date takes you to the agenda for that day 2. You can search for a particular day number, namely search for "Day 150" 3. You can search for a particular week, namely search for "Week 23" 4. The outline can be collapsed to a month. This allows included monthly notes under the month headline. 5. Each month shows all the days of the month and each week stands out because the headline is deliberately longer. Here is the script. Run the script and capture the output in a file, eg diary2009.org import datetime # datetime documented at http://docs.python.org/library/datetime.html # Set yor diary start date on the line below theday = datetime.date(2009, 1, 1) for i in range(0, 380): iso_info = theday.isocalendar() weektag = "" if theday.day == 1: print "* %s %d " % (theday.strftime("%B"), theday.year) if theday.weekday() == 0: weektag = "Week %2d - " % iso_info[1] print "** %s%-3s [%04d-%02d-%02d %3s]" % (weektag, theday.strftime("%a"), theday.year, theday.month, theday.day, theday.strftime("%a")) print "Week %s - Day %s" % (iso_info[1], theday.strftime("%j")) theday = theday + datetime.timedelta(days = 1)