CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to set the date range to start from today and end 7 days later?

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q.
View previous topic :: View next topic  
Author Message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Tue Feb 15, 2005 7:20 pm    Post subject: How to set the date range to start from today and end 7 days later? Reply with quote

To set the range to start from today's date and prevent user from going to previous months, you need to change the gBegin option in the "theme-name".js file to be as following:
Code:
var gBegin=gToday;

To set the range to end 7 days later after today and prevent user from going to future months, you need to change the gEnd option in the "theme-name".js file to be as following:
Code:
var _dEnd=new Date(gToday[0],gToday[1]-1,gToday[2]+7);
var gEnd=[_dEnd.getFullYear(),_dEnd.getMonth()+1,_dEnd.getDate()];


NOTE: The month number used in the javascript Date object is ranged from 0 to 11.

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
por9xp



Joined: 29 Nov 2006
Posts: 3

PostPosted: Wed Nov 29, 2006 9:36 pm    Post subject: Problem when start 2 days before today Reply with quote

Hello:

I want to start 2 days before today, my code run ok in all days of the month but when in days 29, 30 and 31 not run.

Here is my code.

var _dBegin=new Date(gToday[0],gToday[1]-1,gToday[2]+2);
var gBegin=[_dBegin.getFullYear(),_dBegin.getMonth()+1,_dBegin.getDate()];

var gEnd=[2009,12,31];

Where is the problem?, I put an alert and the date is correct but the start calendary is placed in the final date (gEnd). Question

Thanks for all.
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Thu Nov 30, 2006 12:02 am    Post subject: Reply with quote

Actually your code seems to set the range begin 2 days after today instead of before. To set it 2 days before today, you should use the following code instead:
Code:
var _dBegin=new Date(gToday[0],gToday[1]-1,gToday[2]-2);
var gBegin=[_dBegin.getFullYear(),_dBegin.getMonth()+1,_dBegin.getDate()];

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
por9xp



Joined: 29 Nov 2006
Posts: 3

PostPosted: Thu Nov 30, 2006 12:14 am    Post subject: Reply with quote

sorry about my english, I want to say 2 days after (sorry).

In the last days of each month the code not run ok and in the start calendary presents the month of the final date (gEnd).

what happens?
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Thu Nov 30, 2006 3:16 am    Post subject: Reply with quote

Thank you for providing us the link. And here is a detailed explaination and solution. Please be patient while reading...

The problem is very specific when setting today+2 days as the start date based on the DateRange demo, which will result a starting date in the next month when today is at the end of previous month. e.g. if today is Nov 29 the starting date would have to be on Dec 1 - which would effectively disable all dates in the current month. However, the calendar would popup by default showing current month, so this would generate an unwelcomed calendar view with all days disabled unless the user move to the next month.

To avoid the above problem, there is a parameter called SafeMonth (detailed in hello world tutorial) that will take the calendar to the specified month if today's date is out of range.

The default implementation in the PopCalendarXP DateRange Demo uses the month of range end as the safe-month, which in your case caused the problem. To work around, you just need to change the parameter passed into the fPopCalendar() function to use gBegin as SafeMonth instead of gEnd, as following:
Code:
function fStartPop(startc,endc) {
  _startc=startc;
  _endc=endc;
  var sd=fParseInput(endc.value);
  if (!sd) sd=gEnd;
  fPopCalendar(startc, [gBegin,sd,gBegin]);
}

Note the only change we made is at the end of last line, comparing to the original one in plugins.js.

After this change your calendar should be working as expected.

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
por9xp



Joined: 29 Nov 2006
Posts: 3

PostPosted: Thu Nov 30, 2006 9:55 am    Post subject: Reply with quote

Thanks a lot for your help!!

Now my calendars works fine!!

Best Regards. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q. All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group