I'm trying to write a calendar function like this

```
function get_date($month, $year, $week, $day, $direction)
{
    ....
}

```

`$week` is a an integer (1, 2, 3...), $day is a day (Sun, Mon, ...) or number, whichever is easier. The direction is a little confusing, because it does a different calculation.

For an example, let's call 

`get_date(5, 2009, 1, 'Sun', 'forward');`

It uses the default, and gets the first Sunday in May ie 2009-05-03. If we call 

`get_date(5, 2009, 2, 'Sun', 'backward');`

, it returns the second last Sunday in May ie 2009-05-24.