I'm trying to think something through and would welcome any advice or insight.
My project involves listing events for a parish church. Events come in four forms:
a) one-off events (with a simple date and time)
b) regular weekly events (on the same day of each week)
c) regular monthly events type 1 (on the same date each month) - 'monthly-1' below
d) regular monthly events type 2 (on the same set weekday of the nth week) - 'monthly-2' below
e) regular monthly events type 3 (on the last set weekday of the month) - 'monthly-3' below
Regular events may or may not have an expiry date.
Examples:
a) 21:30 on the 5th February 2020
b) every Saturday at 18:30
c) 13:00 on the 10th of each month
d) 12:30 on the third Thursday of each month until 4 April 2020
e) 20:30 on the last Sunday of each month
I would like to be able to set up a 'what's on this/next week' page. The problem is how to get all the events due on a day, in time order.
Given a date, I think I'm probably best to create functions which return the weekday, week number and whether we're in the last seven days of the month. My mind is boggling a little over how to get the events back. I'll need a request for each day of the week which looks like:
So for a page showing a week's worth of events, that's looping seven times over quite a complex "pages" tags to be performed.
Is there an easier (and less typing error-prone) way? Or a better way of thinking about this? Might it even be better to pull the whole lot (i.e all events) back and process the resulting list with PHP or Javascript?
My project involves listing events for a parish church. Events come in four forms:
a) one-off events (with a simple date and time)
b) regular weekly events (on the same day of each week)
c) regular monthly events type 1 (on the same date each month) - 'monthly-1' below
d) regular monthly events type 2 (on the same set weekday of the nth week) - 'monthly-2' below
e) regular monthly events type 3 (on the last set weekday of the month) - 'monthly-3' below
Regular events may or may not have an expiry date.
Examples:
a) 21:30 on the 5th February 2020
b) every Saturday at 18:30
c) 13:00 on the 10th of each month
d) 12:30 on the third Thursday of each month until 4 April 2020
e) 20:30 on the last Sunday of each month
I would like to be able to set up a 'what's on this/next week' page. The problem is how to get all the events due on a day, in time order.
Given a date, I think I'm probably best to create functions which return the weekday, week number and whether we're in the last seven days of the month. My mind is boggling a little over how to get the events back. I'll need a request for each day of the week which looks like:
- Code: Select all
[event date] = [current date]
or
(([event expiry date not set] or ([event expiry date] > [current date]))
and ( ([event is weekly] and ([event day] = [current day]))
or ([event is monthly-1] and ([event date] = [current date]))
or (([event is monthly-2]) and (([event day] = [current day]) and ([event week] = [current week])))
or (([event is monthly-3]) and ([in last seven days] and ([event day] = [current day])))
)
So for a page showing a week's worth of events, that's looping seven times over quite a complex "pages" tags to be performed.
Is there an easier (and less typing error-prone) way? Or a better way of thinking about this? Might it even be better to pull the whole lot (i.e all events) back and process the resulting list with PHP or Javascript?