emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Python script to generate a daily diary/journal
@ 2009-06-26  3:32 Charles Cave
  0 siblings, 0 replies; only message in thread
From: Charles Cave @ 2009-06-26  3:32 UTC (permalink / raw)
  To: emacs-orgmode

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)
    

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-26  3:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-26  3:32 Python script to generate a daily diary/journal Charles Cave

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).