» Forums
» The DHTML Calendar
» General discussion
» Changing Time resolution to 15mins?
Changing Time resolution to 15mins?
2007/12/04 16:32
Viewed 2092 times
Replies: 1/4
by mtka

Hi everyone,

great calendar, has certainly eased my work (and our users) in the past.

I'm currently working on a project were we need to input date and time - but would like to limit that to every 15 minutes instead of 1 min.
Is that possible with the current version? How could I do that myself, if it is not?

Thanks for your help,
Michael

Re: Changing Time resolution to 15mins?
2007/12/07 01:54
Viewed 3003 times
Replies: 1/3

here is how I achieved this.

in calendar_stripped.js:

replace
function makeTimePart(className,init,range_start,range_end){
with
function makeTimePart(className,init,range_start,range_end, interval){interval = interval?interval:1;

Replace
for(var i=range_start;i<=range_end;++i)
with
for(var i=range_start;i<=range_end;i=i+interval)

Replace
var M=makeTimePart("minute",mins,0,59)
with
var M=makeTimePart("minute",mins,0,59,cal.params.minutesInterval)

In calendar-setup_stripped.js:

Insert
param_default("minutesInterval",15);
immediately before
param_default("inputField",null);

Essentially what this does is add the minutesInterval parameter to the set up file. Changing the number from 15 to something else will change the length of intervals used for minutes.

last
Re[2]: Changing Time resolution to 15mins?
2007/12/07 03:02
Viewed 4028 times
Replies: 2/2

on playing around a little more, I have discovered that a little bit more is needed to correctly enforce the intervals.

In calendar_stripped.js:

insert
mins=(mins>=cal.params.minutesInterval)?mins-(mins%cal.params.minutesInterval):0;
after
cal.onSetTime=function(){var pm,hrs=this.date.getHours(),mins=this.date.getMinutes();

Insert
cal.onUpdateTime();
after
M.innerHTML=(mins<10)?("0"+mins):mins;

This will make it so that the actual time rounds down to the closest available allowable interval both in the calendar display, and in the actual time that is set. this will happen as soon as the calendar is opened.

One benefit of this is that it fixes an error where the word "undefined" shows up in the minutes area of the pop-up calendar when one tries to change by dragging immediately after opening the calendar.

last
Google