The web2py in trunk han applications/welcome/views/generic.ics that makes
the calendar. It contains an example. Add to your table two virtual fields
(start_datetime, stop_datetime) and it should work.
On Thursday, 19 April 2012 02:17:48 UTC-5, Annet wrote:
>
> I defined tables Day and OpeningHours:
>
> db.define_table('Day',
> Field('name',length=16,default='',notnull=True,unique=True),
> Field('byday',length=2,default='',notnull=True,unique=True),
> format='%(name)s',
> migrate=False)
>
> db.define_table('OpeningHours',
> Field('nodeID','reference
> Node',default='',notnull=True,ondelete='CASCADE',writable=False,readable=False),
> Field('dayID','reference
> Day',default='',notnull=True,ondelete='RESTRICT'),
> Field('fromTime',type='time'),
> Field('toTime',type='time'),
> migrate=False)
>
> These are the opening hours:
>
> Monday 09:00 - 12:00
> Monday 15:00 - 22:00
> Tuesday 09:00 - 22:00
> Wednesday 09:00 - 12:00
> Wednesday 09:00 - 12:00
> Thursday 09:00 - 22:00
> Friday 09:00 - 22:00
> Saturday 09:00 - 13:00
> Sunday 10:00 - 13:00
>
> When I query the database, rows (OpeningHours and Day joined) read like:
>
> nodeID fromTime toTime byday
> 1 09:00 12:00 MO
> 1 15:00 22:00 MO
> 1 09:00 22:00 TU
> 1 09:00 12:00 WE
> 1 12:00 15:00 WE
> 1 09:00 22:00 TH
> 1 09:00 22:00 FR
> 1 09:00 13:00 SA
> 1 10:00 13:00 SO
>
> I'd like the application to create events on the earliest date that puts
> the
> opening hours in the future and make them downloadable as a .ics file:
>
> BEGIN:VCALENDAR
> BEGIN:VEVENT
> DTSTART:20120423T090000
> DTEND:20120423T120000
> RRULE:BYDAY=MO
> END:VEVENT
> BEGIN:VEVENT
> DTSTART:20120423T150000
> DTEND:20120423T220000
> RRULE:BYDAY=MO
> END:VEVENT
> BEGIN:VEVENT
> DTSTART:20120424T090000
> DTEND:20120424T220000
> RRULE:BYDAY=TU
> END:VEVENT
> ...
> END:VCALENDAR
>
>
> weekday=request.now.weekday() + 1 matches the id of the days.
>
> I wonder whether there is an easy way to relate days to dates.
>
>
> Kind regards,
>
> Annet.
>
>
>
>
>