 |
boardom b2 message board
|
View previous topic :: View next topic |
Author |
Message |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Sun Dec 01, 2002 1:14 am Post subject: Calendar Problem |
|
|
Hmmm, it looks like there is still a calendar problem.
I've just posted to my blog. The date recorded was 1st December (time 00:08 ). This shows on my blog.
However the calendar is still showing the month of November. However it is NOT highlighting the 30th as today's date. And it IS showing a next month link.
If I click on the next month link it correctly displays the month of December with the 1st highlighted.
I suspect this problem will dissappear at 1am. I'll try to look into it before then. _________________ Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't." |
|
Back to top |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Sun Dec 01, 2002 1:23 am Post subject: |
|
|
Even more strange, testing on my server at home (which is in the same time zone as my blog) when I first load my page, the next month link points to January 2003!
Investigating. _________________ Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't." |
|
Back to top |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Sun Dec 01, 2002 2:11 am Post subject: |
|
|
OK, the strangeness at home was because I didn't have a posting on the 1st December!
I think I've fixed the problem (and it wasn't DST it was timezone) but found another one.
At line 52, the calculation of this month and year does not take into account the timezone difference.
So the code: Code: | } else {
$thisyear = date('Y');
$thismonth = date('m');
} |
becomes
Code: | } else {
$thisyear = date('Y', time()+($time_difference * 3600));
$thismonth = date('m', time()+($time_difference * 3600));
} |
This fixes up the displaying of the wrong month.
However you still end up with a next month link which points to the correct next month but the wrong year (January 2002 ) and shouldn't be there at all.
The problem comes in Alex King's mod around line 59:
Code: | $ak_date = mktime(0,0,0,$thismonth,1,$thisyear);
$ak_previous_month = date("m", $ak_date - ((date("t", $ak_date) * 86400) + 86400));
$ak_next_month = date("m", $ak_date + ((date("t", $ak_date) * 86400) + 86400));
|
Because this starts with the 1st of the month, the time difference change doesn't help.
Maybe now that the calculation of $thismonth and $thisyear is correct then this next/prev calculation could simplified.
But in attempting to do this I noticed that Alex's mod doesn't handle the current month being January or December, it doesn't change the year appropriately.
I'll work on that next.
Mike _________________ Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Last edited by mikelittle on Sun Dec 01, 2002 2:32 am; edited 1 time in total |
|
Back to top |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Sun Dec 01, 2002 2:29 am Post subject: |
|
|
OK, I think I've fixed alex's hack too.
the code:
Code: |
// original arrow hack by Alex King
$archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal;
$ak_date = mktime(0,0,0,$thismonth,1,$thisyear);
$ak_previous_month = date("m", $ak_date - ((date("t", $ak_date) * 86400) + 86400));
$ak_next_month = date("m", $ak_date + ((date("t", $ak_date) * 86400) + 86400));
$ak_first_post = mysql_query("SELECT MONTH(MIN(post_date)), YEAR(MIN(post_date)) FROM $tableposts");
$ak_first_post = mysql_fetch_array($ak_first_post);
// using text links by default
$ak_previous_month_dim = '<span><</span> ';
$ak_previous_month_active = '<a href="'.$archive_link_m.$thisyear.$ak_previous_month.$querystring_separator.$month[zeroise($ak_previous_month,2)].'-'.$thisyear.'" style="text-decoration: none;"><</a> ';
$ak_next_month_dim = ' <span>></span>';
$ak_next_month_active = ' <a href="'.$archive_link_m.$thisyear.$ak_next_month.$querystring_separator.$month[zeroise($ak_next_month,2)].'-'.$thisyear.'" style="text-decoration: none;">></a>';
$ak_previous_month_link = (mktime(0,0,0,$ak_previous_month,0,$thisyear) < mktime(0,0,0,$ak_first_post[0],0,$ak_first_post[1])) ? $ak_previous_month_dim : $ak_previous_month_active;
$ak_next_month_link = (mktime(0,0,0,$ak_next_month,0,$thisyear)> mktime()) ? $ak_next_month_dim : $ak_next_month_active;
|
becomes:
Code: |
// original arrow hack by Alex King
$archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal;
$ak_previous_year = $thisyear;
$ak_next_year = $thisyear;
$ak_previous_month = $thismonth - 1;
$ak_next_month = $thismonth + 1;
if ($ak_previous_month == 0) {
$ak_previous_month = 12;
--$ak_previous_year;
}
if ($ak_next_month == 13) {
$ak_next_month = 1;
++$ak_next_year;
}
$ak_first_post = mysql_query("SELECT MONTH(MIN(post_date)), YEAR(MIN(post_date)) FROM $tableposts");
$ak_first_post = mysql_fetch_array($ak_first_post);
// using text links by default
$ak_previous_month_dim = '<span><</span> ';
$ak_previous_month_active = '<a href="'.$archive_link_m.$ak_previous_year.zeroise($ak_previous_month,2).'" style="text-decoration: none;"><</a> ';
$ak_next_month_dim = ' <span>></span>';
$ak_next_month_active = ' <a href="'.$archive_link_m.$ak_next_year.zeroise($ak_next_month,2).'" style="text-decoration: none;">></a>';
$ak_previous_month_link = (mktime(0,0,0,$ak_previous_month,1,$ak_previous_year) < mktime(0,0,0,$ak_first_post[0],1,$ak_first_post[1])) ? $ak_previous_month_dim : $ak_previous_month_active;
$ak_next_month_link = (mktime(0,0,0,$ak_next_month,1,$ak_next_year)> mktime()) ? $ak_next_month_dim : $ak_next_month_active;
|
Edit After IM-ing with Alex I've added another fix (and I've removed a couple of my extras)
Hope this helps,
Mike _________________ Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't." |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Sun Dec 01, 2002 4:19 am Post subject: |
|
|
Mike, thanks for all your help fixing this. I've updated the zip file on my site with the bug fixes. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Sun Dec 01, 2002 10:18 am Post subject: |
|
|
Bad news, it is after 1am on Dec 1st and my calendar isn't showing December... must still be a bug in there somewhere. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Sun Dec 01, 2002 4:50 pm Post subject: |
|
|
No, I think it's designed to only show months in which there are postings.
That is, it will not show months beyond the first or last posting date.
Although, if you pass in m=200301 it will display that calendar.
Mike _________________ Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't." |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Sun Dec 01, 2002 5:16 pm Post subject: |
|
|
ahh, so it's a feature then _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
Anavy
Joined: 29 May 2002 Posts: 58
|
Posted: Tue Dec 03, 2002 10:35 pm Post subject: |
|
|
I'm using b2calendar.php Rev. 1.12 (CVS) that includes alex_t_king's hack. I've posted today & the calendar changed to Dec. 2002 properly - but now it shows the Next_Month as 1/2002 instead of 1/2003 (none should be allowed as both has no posts).
Did anyone noticed this behavior? |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Tue Dec 03, 2002 10:55 pm Post subject: |
|
|
Yes, there was a bug in my code - grab the latest version from my site. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Wed Dec 04, 2002 6:20 am Post subject: |
|
|
i used the fixded code by mike little and it is solved _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Wed Dec 04, 2002 8:57 am Post subject: |
|
|
Good deal, the zip on my site includes his fixes as well for those who'd rather not edit the code directly. Thanks again Mike. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
Anavy
Joined: 29 May 2002 Posts: 58
|
Posted: Wed Dec 04, 2002 2:21 pm Post subject: |
|
|
Thanks Alex. The new version fixed the problem. |
|
Back to top |
|
 |
Mister44

Joined: 31 Oct 2002 Posts: 237 Location: Philadelphia, PA, USA
|
Posted: Fri Dec 06, 2002 9:20 pm Post subject: |
|
|
Just a couple minor changes - fix a querystring bug and improve the XHTML compatability.
first the querystring bugfix - lines 278 to 281 - should be Code: |
echo '<a href="'.$siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$thisyear.$thismonth.date('d',$i).'" class="b2calendarlinkpost" title="'.$ak_day_titles.'">';
}
else {
echo '<a href="'.$siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal.$thisyear.$thismonth.date('d',$i).'" class="b2calendarlinkpost">';
|
For XHTML -- its basically adding the thead and tbody elements - you can grab the fully patched file from here.
Alex, feel free to add these changes back into your distro.
(And can I just say how much I hate the code tags in phpBB? the echo lines shouldnt wrap.) |
|
Back to top |
|
 |
Mister44

Joined: 31 Oct 2002 Posts: 237 Location: Philadelphia, PA, USA
|
Posted: Fri Dec 06, 2002 11:06 pm Post subject: |
|
|
I really am not having a good code day. If you grabbed a copy in the last hour and a half, there's a glitch in the thead. Pick up a new copy - same location. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2 © 2001, 2002 phpBB Group
|