Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a calendar view with a granularity of week. My expectation is going to my view url with no arguments (default set to current time) the proper week would show. However, the view is a week behind (http://dctv.davismedia.org/schedule).
I read the report "Add option to use ISO 8601 week numbers" at http://drupal.org/node/641344 but don't feel this issue is about whether the format is ISO 8601 or not. I tried to force the default argument to now() + 1wk but had no luck there. Any solutions or tips are appreciated. Thanks.
Comment | File | Size | Author |
---|---|---|---|
#65 | 686394-3.diff | 1.45 KB | darrick |
#52 | 686394-52_Week default argument.patch | 1.37 KB | arlinsandbulte |
#7 | 686394-2.diff | 1.18 KB | darrick |
#4 | date.diff | 1.27 KB | darrick |
Comments
Comment #1
rbrownellI am having the exact same problem. It seems like it happened immediately after the new year or with a recent upgrade of the date module. How do we fix this!?
Comment #2
HunterElliott CreditAttribution: HunterElliott commentedYep, happening to me, too... but it actually looks almost 2 weeks off.
Comment #3
HunterElliott CreditAttribution: HunterElliott commentedI think I see why it's happening - and I don't see where I should fix this... any suggestions on how to do so would be welcomed.
When I look in the View for my Calendar, you know it's got the various displays for Week, Month, Year, etc... the issue that most of them had "month" as the default value in Argument instead of the correct daypart is minor and easily fixed... but when I look at the Week display and preview said display... well, looking at the SQL generated I see why it's a week off.
The Week's SQL has this in it:
LEFT JOIN content_type_nodetype node_data_field_fieldname_date ON node.vid = node_data_field_fieldname_date.vid
WHERE ((node.status <> 0) AND (node.type in ('nodetype')))
AND ((ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(-18000)) <= '2010-01-18 00:00:00' AND ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(-18000)) >= '2010-01-11 00:00:00'))
ORDER BY node_data_field_fieldname_date_field_fieldname_date_value ASC
The 'nodetype' and "fieldname' bits are me changing the name of those items here... but today is the 18th and the sql is saying "display a weeks worth of events prior to the current week" (i have monday as the start day - if i chose sunday, it'd be two weeks prior)
I've been searching around in the code and am not finding where the sql statement to choose the "week value".
Comment #4
darrick CreditAttribution: darrick commentedI did find a fix. Which is a total hack but it works. This issue is related to http://drupal.org/node/641344 and is a bug in the date_api module. As stated in that issue the date module does not use ISO 8601 format for the date week format. However, the default argument in the week granularity view is in ISO 8601.
I've attached a patch and will cross-post to issue 641344.
Comment #5
my-family CreditAttribution: my-family commented#4 seems to work ok with date browser and calendar week view as well... Thank you
Comment #6
Junro CreditAttribution: Junro commentedSame problem for me :(
Comment #7
darrick CreditAttribution: darrick commentedI fixed some issues with the last patch I submitted. Also discovered you need to set "First day of week:" to monday at admin/settings/date-time.
Comment #8
seanmcginley CreditAttribution: seanmcginley commentedPatch solves my issue. Thanks darrick!
Comment #9
rbrownellWhere is the file that we are patching this to? I can't find it!
never mind... stupid question.
Comment #10
windancer055 CreditAttribution: windancer055 commentedI tried the patch (actually both of them), but my calendar still displays the previous week by default, any idea?
Comment #11
MBroberg CreditAttribution: MBroberg commentedI tried the patch in #7 at 9:45pm on Sun, Jan 31. It previously said "Jan 17" in the date changer, and now it says "Jan 24."
So I changed the +7 in the patch to a +14 and the date is correct.
I assume there are still some issues with this that will recur on other days.
However I do not want to change my start D.O.W. to a Monday.
#10 are you caching?
Comment #12
dopry CreditAttribution: dopry commentedI can confirm I was having the same issue. subscribing to wait for an official fix.
Comment #13
Gribnif CreditAttribution: Gribnif commentedsubscribe
Comment #14
ale_89 CreditAttribution: ale_89 commentedsubscribe
Comment #15
marcushenningsen CreditAttribution: marcushenningsen commentedsubscribe
Comment #16
Junro CreditAttribution: Junro commentedCritical, because... well, my users live in the past since the beginning of the year, with one week late! lol
Comment #17
coreyp_1 CreditAttribution: coreyp_1 commentedThis is not a proper answer to the problem, but it it a module-based work-around using the hook_views_query_alter().
Basically, every site that I work on needs some custom module work, and I put all of the odd and end functions into a misc module (providing that the task is not large enough to warrant a separate module). Here is what I included in my misc.module:
Obviously, you would need to modify this somewhat to fit your needs. In my case, the view was at url
/shows/*argument here*
, so it made sense to test for the presence of arg(1). My view was namedepisodes_weekly
, so you would need to change that to the appropriate view name. Also, the argument in question just happened to be the first (and only) argument for the view, so it made sense to put the new argument value into$view->args[0]
. Your implementation may need the argument placed in a different place in the array if your arguments are configured differently.This code assumes that Sunday is the first day of the week. I didn't want to make it any more flexible, since I assume that this is only a temporary solution until the correct patch makes it in. I just wanted to provide a simple, non-hacking alternative that will fix the problem until a proper solution can be implemented.
Comment #18
juhovaltonen CreditAttribution: juhovaltonen commentedsubscribe
Comment #19
Skorpjon CreditAttribution: Skorpjon commentedThe patch from darrick works for me. Thank you.
Comment #20
marcvangend@#17: your approach looked good to me, because I rather not patch too many files. Unfortunately, the code breaks when the path of the view has two or more elements. For example, it works fine if your view is located at www.example.com/calendar, but it breaks on www.example.com/events/calendar. In that case, arg(1) will return 'calendar' so the rest of the script is not executed. I could not find a way to determine if the argument has been created as a default argument, or if it's actually passed to the view in the url. Since changing the path is not an option in my case, I will use the patch from #7.
Comment #21
coreyp_1 CreditAttribution: coreyp_1 commentedThe code doesn't break, but it does have to be modified for your use. It is custom code, after all. That's why I pointed out that I used
arg(1)
. If your url is different, then the argument would be in a different place (likefoo/bar/*argument here*
would usearg(2)
).in your case (
events/calendar
), you would be testing for arg(2).If you used
foo/bar/baz
, then you would use arg(3), and so on...Comment #22
marcvangendOf course I can modify code, that's not the point. I'm not criticizing you or your code, I just wanted to share why I ended up using the patch instead of the hook_views_query_alter solution. In my specific situation, having to modify the code is not good enough. I searched for a way to make the code "self-modifying" but I could not find it. I'm sorry if I didn't make myself clear in #20.
Comment #23
Junro CreditAttribution: Junro commentedPatch from Darrick works! Thanks
Comment #24
harryadu CreditAttribution: harryadu commented"Your patch didn't work", "Yes, it did, you just entered it wrong", BLA BLA BLA!! People are just too sensitive on these forums! Let's not get too touchy on here. After all, it's nothing personal. Wow!
Comment #25
Qluripax CreditAttribution: Qluripax commentedsubscribe
Comment #26
marcushenningsen CreditAttribution: marcushenningsen commentedI fixed this by applying the patch in #641344: Add option to use ISO 8601 week numbers. I know you are aware of that issue, and I know they are different, but still I just wanted to let you know.
Comment #27
webwriter CreditAttribution: webwriter commentedSubscribe
Comment #28
webwriter CreditAttribution: webwriter commentedThis doesn't appear to be fixed in the new dev release... still defaulting to a week behind.
Comment #29
HnLn CreditAttribution: HnLn commentedsubscribe
Comment #30
kettari CreditAttribution: kettari commentedPatch of #7 fixed this issue for me.
Comment #31
vorbian CreditAttribution: vorbian commentedsubscribe
Comment #32
Wappie08 CreditAttribution: Wappie08 commentedI'm experiencing the same problem with current versions Calendar/DateAPI, I like the hook_alter, thanks coreyp_1!
Is #7 going to be committed?
Greetings Wappie
Comment #33
rbrownellThis issue was not resolved in the latest release!
Comment #34
robbertnl CreditAttribution: robbertnl commentedSame issue. Using #7 as well. tried #17 first but is not working in my situation (deeper path level and i am using multiple displays on the same page).
Looking forward for a commit in the next release.
Comment #35
milehighlife CreditAttribution: milehighlife commentedThank you darrick, patch on #7 worked for me as well (used in Calendar Views with an argument needing granularity of week). I'm subscribing in case the patch is committed to a future release.
Comment #36
benjamin_dk CreditAttribution: benjamin_dk commentedsubscribe
Comment #37
davidhernandezsubscribe
Comment #38
Wappie08 CreditAttribution: Wappie08 commentedKarenS, what do you think of the issue / patch#7?
Greetings Wappie
Comment #39
hawkbreeze CreditAttribution: hawkbreeze commentedsubscribe
Comment #40
arlinsandbulte CreditAttribution: arlinsandbulte commentedThis may have been fixed by #641344: Add option to use ISO 8601 week numbers, which was recently applied.
Could someone confirm or deny that, please?
Make sure you use the -dev with the #641344 patch applied (or a direct CVS checkout).
That means you will need a -dev with an August 13, or later date.
&
Make sure that you configure your site's date settings to First week: Monday & enable the 'Use ISO-8601 week numbers' option.
Comment #41
MBroberg CreditAttribution: MBroberg commentedPersonally, I am hesitant to go this route because I do not want my first day of week to be Monday. So even if the patch works, that requirement would still not make the whole issue "fixed."
I am still using my hack in #11 and it works for most situations, but I am hoping for the "Monday" requirement to be removed, if at all possible.
Thanks for your efforts.
Comment #42
webwriter CreditAttribution: webwriter commented+1 MBroberg. I really can't display calendars starting on Monday because I am displaying full weeks, not work weeks. A calendar that starts Monday shows next week's Sunday...
Comment #43
akolahi CreditAttribution: akolahi commentedI can confirm that for me #641344: Add option to use ISO 8601 week numbers fixes this issue for me. Of course first day of the week has to be Monday, but for me this is not so bad.
Comment #44
rbrownellHas the patch in #7 been committed yet? It seems to be the best solution.
Comment #45
bendiy CreditAttribution: bendiy commented#7 worked for me, but I had to change the 7:
To 14:
I'm not sure what is causing the 14 or 7 days offset. This could probably get included in Date API if there was some setting options for it at "/admin/settings/date-time". Having the first day of the week set to Monday just doesn't work in the US.
Comment #46
bendiy CreditAttribution: bendiy commented@ #40, the fix for #641344: Add option to use ISO 8601 week numbers works, but is not the best solution if you need your weeks to start on Sunday.
Comment #47
alphex CreditAttribution: alphex commentedsubscribing
Comment #48
rbrownellHas there been any work on this even towards a commit? This issue renders the module useless for several people.
-R
Comment #49
rbrownellComment #50
rbrownell#641344: Add option to use ISO 8601 week numbers is insufficient to solve this problem. Currently, the best solution is in number 7... Is it ever going to be committed?
Thinking in regards to the other post (though the ISO standard states that Monday is the first day of the week)
Standards pushed aside, couldn't it be a cosmetic issue instead of a major standards violating one?
There's got to be a better way of dealing with this.
Comment #51
arlinsandbulte CreditAttribution: arlinsandbulte commented#7 does not work if the "Use ISO-8601 week numbers" option is enabled at /admin/settings/date-time.
I am working on a patch to correct that.
Comment #52
arlinsandbulte CreditAttribution: arlinsandbulte commentedPatch that addresses #51 attached.
I'm not entirely convinced this is the right way to fix this. It is very hacky and sort of band-aids the real problem, IMO.
But, at least for the calendar view, it seems to work.
Also, this patch is actually applied to the Date module, so by rights, this is probably a Date issue.
But, the problem seems to manifest itself in Calendar, so I will leave this in the Calendar issue queue for now.
Comment #53
bendiy CreditAttribution: bendiy commentedLooks fine, but this doesn't fix the 14 vs. 7 days offset issue. See #45. Adding a form field to "/admin/settings/date-time" that sets a variable for the 14 or 7 days offset is one solution. I haven't looking into why I'm getting 14 days and not 7, but others are as well, see #11.
Comment #54
arlinsandbulte CreditAttribution: arlinsandbulte commentedArg! I did not notice the 7 vs 14 day offset issues above.
I assumed the problem was that ISO week number could be different than the 'calendar' week number, and that the most these two different week numbers could be different is by 1 week (7 days), not 2 weeks (14 days).
Any idea why some sites require a 7 day offset correction while other require 14 days?
Do you have your timezone set at /admin/settings/date-time?
Does
dsm(date("Y-m-d g:ia", time()));
return the correct (current) time for you?Comment #55
addisonj CreditAttribution: addisonj commentedsubscribe
lets hope for a commit soon
at least I have a fix now though
Comment #56
bendiy CreditAttribution: bendiy commentedFunny thing, last night the site I've been working on was offsetting too far using 14 days. I switched it back to 7. However, when 14 was working, it was on a Sunday. I think there may be a problem on Sundays using the 7 days setting. I'll try and check what the site is doing this Sunday to verify.
Comment #57
thehong CreditAttribution: thehong commentedThe reason is, in date_week_range() function, it's being:
And it should be:
Comment #58
bendiy CreditAttribution: bendiy commentedReporting back... It's Sunday the 12th and my week calendar is showing last week, 5th through 11th. The patch code is currently set to 7 days.
Can anyone else confirm this?
Comment #59
albert9000 CreditAttribution: albert9000 commentedMine is doing the same.
Comment #60
axoplasm CreditAttribution: axoplasm commented#7 works for me as well. Also want to echo comments by nfd (#48/#50) and others.
Comment #61
aaron.r.carlton CreditAttribution: aaron.r.carlton commentedsubscribing - i can't use #7 since my week starts on sunday. looking forward to a robust fix.
Comment #62
eclauset CreditAttribution: eclauset commentedsubscribe
Comment #63
Johan den Hollander CreditAttribution: Johan den Hollander commentedSubscribing, my week starts on a sunday too...
Comment #64
crutch CreditAttribution: crutch commentedsubscribe, patch works #52 thanks
Comment #65
darrick CreditAttribution: darrick commentedI reworked my patch. Tested with the "Use ISO-8601 week numbers" both on and off.
The patch is against the latest cvs. It also fixes the issue with the first week being off by a year.
Comment #66
rbrownellI must say I am tremendously disappointed that this was not fixed in the most recent release. It has been over a year and this has not gotten the attention it disserves. Thank you darrick for your patches, they have been a valueable resource!
-R
Comment #67
rbrownellLooking at the patch it is applied to the date module, has this issue been reported on the date module's issue queue? Perhaps we should move it?
Comment #68
KarenS CreditAttribution: KarenS commented@nfd, I am not going to apply patches that are submitted saying 'this is a total hack', and I don't have time right now to find something that is not a hack. I had to get a release out because lots of important fixes had been made, just not this one. I can't wait until the issue queue is empty to do a release.
Comment #69
KarenS CreditAttribution: KarenS commentedI also see that there is a new patch that may not be a hack at #65, but it came in after I finished the release and it needs to be tested.
Comment #70
KarenS CreditAttribution: KarenS commentedComment #71
bendiy CreditAttribution: bendiy commentedCan anyone verify that #65 handles Sundays properly. The previous patch gave you the prior week on Sundays, but come Monday, it would be the correct week.
Comment #72
rbrownell@KarenS. I appreciate that you don't have a lot of time to commit to every issue and thank you greatly for your hard work. It just feels though as if this issue (a whole year later) has not gotten the attention it deserves because it is indeed a function crippling issue. Perhaps enforcing or getting people to assist with enforcing the designation of what is critical and what is not may help with better prioritizing the issue queue. I am pleased though that now you have actually looked at/posted to this issue.
I find it odd that such a critical/popular module really only has you making contributions with the vast majority of commits. It is a shame that there isn’t anyone else as dedicated as you are to contribute to the Date and Calendar modules as much as you do. I wish I could help, but I barely can program a form that pushes data to PayPal, let alone a complex time calculating module such as this. Thanks for all of your hard work!
@bendiy I can confirm that it handles Sunday's properly. It was easy to install and works well. :)
Comment #73
KarenS CreditAttribution: KarenS commentedCommitted a different fix. I found a non-hacky way to do this. We have a nice API to compute the week, we don't need to do it here.
Comment #74
marcvangendThat's excellent news. Thanks Karen!
Comment #75
rbrownellExcellent! Thank you for fixing this. :)
Comment #76
seaneffel CreditAttribution: seaneffel commentedKaren, I notice that your commit fixed this issue through the Date module rather than the Calendar. Just marking it as such.
Comment #78
Kman2123 CreditAttribution: Kman2123 commentedI am having this bug still because I am waiting on the recommended release. When do you think you will update the dev version to recommended status?
Comment #79
rbrownell@Kman2123 it should be in the latest release! :D
Comment #80
Kman2123 CreditAttribution: Kman2123 commented@nfd The patch for this issue was only released in the dev version and not the stable release version. Do you know when the stable release will be updated to include the patch in the dev release?
Comment #81
seaneffel CreditAttribution: seaneffel commentedI've just moved from 6.x-2.7 recommended release to the 6.x-2.7-dev version of Nov 27, 2011 and it did fix the issue of showing the wrong week's date in the calendar week view.
I'm updating the status on this because the comment in #80 is correct. The patch that fixes this was applied only to the dev version and not the official release. I think its appropriate to keep this issue open until the official release contains the fix.
Comment #82
Kman2123 CreditAttribution: Kman2123 commentedGood to hear it has been fixed. Hopefully they will update the recommended version here soon!
Comment #84
arlinsandbulte CreditAttribution: arlinsandbulte commentedFixes are never applied to the 'official' point releases. Once a point release is made, it is a snapshot that is never again changed.
All fixes are applied to the -dev versions. Later, once the module maintainer deems it a appropriate time, they create a new 'official' point release from the -dev that supersedes the previous 'official' release.
This issue has been fixed, and marked as such.
The next 'official' point release will include this fix.
Comment #86
scotwith1tI am still having this problem as of today (3/15/12)...was using 2.8, had the issue present and just pulled down the latest dev to make sure...can we check this again? i click the week view today and get the week of 2/26/12. I fi then click on month, i'm in february...click on year and my month now links to december, my week to W48 my day to 12/1/12...i don't get it. i didn't change any arguments, it's still got the 'provide default argument - current date' argument...any ideas?
Comment #87
my-family CreditAttribution: my-family commentedPlease, could anybody provide a link to the version where this bug is fixed? I can't find any 6.x-2.7-dev version of Nov 27, 2011 (see #81). Thank you in advance.
Comment #88
marcvangendmy-family: "6.x-2.7-dev" must be a mistake, in Drupal versioning a dev version would be called "6.x-2.x-dev". This fix should be included in the latest version (6.x-2.9) because it's much more recent than this issue. If it's not, re-open this issue or create a new one.
Comment #89
DamienMcKennaUnfortunately the Drupal 6 version of the Date module is no longer supported. That said, we appreciate that you took time to work on this issue. Should this request still be relevant for Drupal 7 please feel free to reopen it. Thank you.