designing a usable notation for returning events

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
tsr
Forum Newbie
Posts: 9
Joined: Tue Apr 19, 2005 11:21 am

designing a usable notation for returning events

Post by tsr »

Hi,

This is not the point, just a little background:
I'm in the process of developing a small app that will produce a calendar.

What I would love to do is to create an easy way for users to add events that will rerturn like: yearly, every first monday of the month, every week, every three weeks, every 3 months except if it's on a sunday, etc.

And (here comes the point!) I would love to make it so that it's just editing a text-file. Like some kind of regex for dates that humans and computers can read almost as easily (leaning towards humans, in contrast to regexs).

Anyone got any ideas?

I've got some kind of feeling that the date-format constants used for date(format, timestamp) could be useful in some way.

What I'm aiming at is something like:

yearly(24/12): fill up chimney with broken glass
monthly(monday(1):17.15): call probation officer
daily(21.00): go to bed as to preserve some kind of sense of humor

/tsr
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

My idea is to read the text file line by line, split up each line and figure out what it means, and then display the calendar.
(#10850)
tsr
Forum Newbie
Posts: 9
Joined: Tue Apr 19, 2005 11:21 am

yes, but...

Post by tsr »

...what I'm interrested in at the moment is how to the notation should look like.

I'm aiming at some kind of notation that could represent a recurring event how-ever (or at least almost) it would be represented in a natural language.

The parsing of it is a later question.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What about a crontab like syntax for repeating events (and just a date-time for singluar events) ?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

You know, there is a PHP calendar/to do app that does something like this. I forget what the project is called, but if you search Freshmeat.net you can probably find it.
(#10850)
tsr
Forum Newbie
Posts: 9
Joined: Tue Apr 19, 2005 11:21 am

Post by tsr »

feyd: good idea, I'll look into that. (Nope, sorry, it doesn't seem to quite meet my req of being able to say 'the first saturday of every month, except july and dec')

arborint: thanks, do you have any more info for me on this, so that I don't need to evaluate some 50+ projects (searching for "calendar to-do" in PHP on freashmeat actually got me 84 projects)

Ah, well I'll maybe just dig into iCal more...

/tsr
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

tsr wrote:feyd: good idea, I'll look into that. (Nope, sorry, it doesn't seem to quite meet my req of being able to say 'the first saturday of every month, except july and dec')
With a little wrapper it's relatively easy to achieve though...

Eg, run on the first seven days of the month at 9am, check if it's saturday, and then do your thing...

0 9 1-7 * * run-on-dow Sat echo "Wake up! xxx needs a yyy!"

Where run-on-dow is something like:

Code: Select all

#!/bin/bash
if [ `date +%a` = $1 ]; then
    shift
    exec "$@"
fi
Post Reply