emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Python script to generate a daily diary/journal


From: Charles Cave
Subject: [Orgmode] Python script to generate a daily diary/journal
Date: Fri, 26 Jun 2009 03:32:37 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.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)
    











reply via email to

[Prev in Thread] Current Thread [Next in Thread]