What I would really like to see is a some kind of `when` clone with
cron-like syntax written in C.

I have just written very simple prototype of it in rc:

    #!/usr/bin/env rc
    date=`{date}
    month=$date(2)
    day=$date(3)

    while (line=`{read}) {
        if ({~ $line(1) '*' || ~ $line(1) $day} &&
            {~ $line(2) '*' || ~ $line(2) $month})
                echo $line(3-)
    }

Syntax looks like this:

    # DAY MONTH TEXT
    15      Aug     ok
    16      Aug     not ok
    *       *       always ok

When started with

    when <~/lib/calendar

it outputs

    ok
    always ok

It will output "not ok" tomorrow.

I don't think this should be written in shell scripting language: it
is not too easy to calculate what date it will be tomorrow without
libc and it should be very fast.  Also there should be more fields for
hours, minutes, year and day of week, items should be sorted by time
and there should be some items with dates that are in the feature.

I store my TODO items in file named "TODO" so no need to support for
them in personal calendar program.

- - -

Also just found "calendar" program in plan9port:
http://plan9.bell-labs.com/magic/man2html/1/calendar

I will try it, probably it is even better than my idea.


Reply via email to