Board Logo

Setting default time values
garlinx - 10/12/2009 at 12:04 PM

Congrats on an excellent tool which works very well.

I do however require some help with the following:

I have a form with two input fields i.e. startDate and endDate.

I am trying my best to customise the calendar_db.js script to enable the tigra calendar to automatically attach the time 00:00 to the startDate e.g. 2009-10-01 00:00 and the time 23:59 to the endDate e.g. 2009-10-31 23:59, but unfortunately without any success.

Would be very thankful for at least a tip in the right direction.

EDIT:

I have been able to enable the tigra calendar to pass a single default 00:00 to the selected date as follows:

function f_tcalGenerDate (d_date) {
return (
d_date.getFullYear() + "-"
+ (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate()
+ " 00:00" // THIS LINE ADDED BY GARLINX!!
);
}

but this applies unfortunately to both input fields i.e. both startDate and endDate.


garlinx - 10/13/2009 at 03:18 PM

Hi again.

Am unfortunately still battling with this problem. :(

Is there any way that this can be achieved?

Or maybe it is simply not possible...

Many thanks.


garlinx - 10/14/2009 at 10:15 PM

OK. I think I have found the solution to my problem.

It was necessary to expand the function f_tcalGenerDate() in the calendar_db.js file as follows:

// date generating function
function f_tcalGenerDate (d_date) {

if (this.a_cfg.controlname == 'startDate') {
return (
d_date.getFullYear() + "-"
+ (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate()
+ " 00:00"
);
}
else if (this.a_cfg.controlname == 'endDate') {
return (
d_date.getFullYear() + "-"
+ (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate()
+ " 23:59"
);
}
}

where my two input boxes are named startDate and endDate respectively.


I also had to expand the accepted regular expression in the function f_tcalParseDate()
from
var re_date = /^s*(d{2,4})-(d{1,2})-(d{1,2})s*$/; // e.g. YYYY-MM-DD
to
var re_date = /^s*(d{2,4})-(d{1,2})-(d{1,2})s*(d{1,2}):(d{1,2})s*$/; // e.g. YYYY-MM-DD HH:MM


Please forgive any potential errors or bugs in the above - I have next to no knowledge of Javascript.. :)


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/