tbar0970 / jethro-pmm

Jethro Pastoral Ministry Manager
GNU General Public License v3.0
36 stars 26 forks source link

iCal feed dates are all 1970 #146

Closed jefft closed 8 years ago

jefft commented 8 years ago

When I log in to Jethro, I see an 'Upcoming Roster Allocations' section with 1 item ("6 Mar, Arvo Roadeez"). I click 'Subscribe' and view the contents of the generated iCal. The DTSTART and DTEND fields are both 1970:

root@coastserver:~# curl 'https://jethro.coastec.net.au/public/?call=roster_ical&uuid=Qm1ePMJMkGRDSD8YIvhB4jVLFhK18LuAqyXc3pH8vCfJVLi9bNddwX806DPX'
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Jethro/Jethro//NONSGML v1.0//EN
X-WR-CALNAME:COAST Evangelical Roster
BEGIN:VEVENT
UID:536_1_20160306@jethro_roster
ORGANIZER;CN=Coast Evangelical:MAILTO:webmaster@coastec.net.au
DTSTART:19700101T000000Z
DTEND:19700101T010000Z                
SUMMARY:Roadeez
DESCRIPTION:Roster assignment: Roadeez, Arvo, COAST Evangelical\n\nRole description: https://jethro.coastec.net.au//public/?view=display_role_description&role=1  \n\nNote that start/end time is approximate.
END:VEVENT
END:VCALENDAR

This happens for multiple users in our Jethro, previously on v2.13.1 and now on 2.14.2.

tbar0970 commented 8 years ago

Can you check the "code name" value for your congregations. They need to include an HHMM start time, but legacy values may not include this.

jefft commented 8 years ago

Hi Tom,

Thanks, that hint helped me figure out the problem. We have congregation code 'arvo_1600'. Jethro is not parsing the time from this, despite it being legal according to the help text ("An HHMM time must be present within the value (eg ash_0930_late).")

The relevant code is db_objects/service.class.php line 755:

        public static function getMeetingDateTime($meetingDate, $meetingTime) {
                $dateString = date('Y-m-d', $meetingDate);
                if ($meetingTime != NULL && preg_match('/\\d\\d\\d\\d/', $meetingTime)) {
                        // Time is specified and valid.
                        $dateString .= ' ' .
                                substr($meetingTime, 0, 2) .
                                ":" .
                                substr($meetingTime, 2, 2) . ':00';
                }
                return strtotime($dateString);
        }

The substr's are too simplistic, as they assume the first 4 characters are always the timestamp, whereas in 'arvo_1600' they're not.

tbar0970 commented 8 years ago

Thanks for investigating, Jeff. Now fixed.