I want to set up a weekly calendar using Date and Calendar modules. I need to set the default argument in Views to Week granularity so that it displays the weekly calendar. However, when viewing the view, the Date API throws this error at me:

recoverable fatal error: Object of class DateTime could not be converted to string in /home/ali30873/domains/my.site/public_html/sites/all/modules/date/date_api.module on line 1190.

I used the Devel module's dsm() function to take a peek at the object and it seems to be empty.

It only seem to be throwing this argument with the default argument set to the current date.

For example, if I go:

http://my.site/testcalendar

It throws up the error. But if I go:

http://my.site/testcalendar/2011-W5

It doesn't throw up any error.

Comments

DMacpherson’s picture

Title: Problem with Date API when using Calendar with argument set to "Week" granularity » Problem with Date API when using Calendar with argument set to "Week" granularity and "current date" default argument
mkahn’s picture

Ditto. I have updated to the dev version of date 6.x-2.x-dev, and using php 5.2.

HallSL’s picture

Same here. I just updated Date and Calendar to most recent dev versions and am getting this error:

recoverable fatal error: Object of class DateTime could not be converted to string in /home/riverrep/public_html/sites/all/modules/date/date_api.module on line 1189.

The week that is defaulted to, using the current date, throws the error:

http://www.riverreporteronline.com/where-when

When the specific week is paged to, it's fine:

http://www.riverreporteronline.com/where-when/2011-W8

RKopacz’s picture

I am having same problem. Has solution been reported somewhere?
Need to get this fixed. I have rolled back to ver 2.7 to see if that works again.

jpsolero’s picture

Status: Active » Needs review
StatusFileSize
new606 bytes

I fix it with this code at date_api_argument_handler.inc

$week = date_week(date_format($now, 'Y-m-d'));

instead of

$week = date_week($now);

Seems its passing and object instead of the formated date.

akolahi’s picture

Patch in #5 fixed the issue for me

thedavidmeister’s picture

wow, this issue took me ages to find, but patch in #5 worked for me too, thanks!

samireez’s picture

Patch in #5 works great. Thanx!

svarco’s picture

subscribe

jherencia’s picture

Status: Needs review » Reviewed & tested by the community

It works for me too, it's been too long since @jpsolero posted this patch and no mantainer got into this, maybe it helps if we change the status to reviewed & tested by the community.

@svarco subscribe does not work anymore that way, now you can follow:
http://drupal.org/node/1306444

arlinsandbulte’s picture

This looks correct to me.
And the same issue appears to exist in the D7 version of date too. Attached is a D7 patch.

arlinsandbulte’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.