woensdag 28 oktober 2009

New Running goal 2010

Finally we have a new running goal in 2010. We are going for the 20 Miles of Graubunden in Switzerland.
Nice to have new goal. It will be a hard one, about 1200 meters uphill.
You will running most of it on trails, so I think it's time for real trailshoes.

woensdag 21 oktober 2009

Xpage: Selected value of a Listbox

I'm buiding a new Xpage application, now I'm facing a problem.
On the Xpage is a Listbox, with possibilty to store multiple values.

Is there an easy way to get the selected value of the Listbox with Server Side Javascript?

donderdag 8 oktober 2009

Xpage: getWeek() function in Server Side JS

I'm busy with the rebuild of our Planning database. To display the planning of the employees you will need the weeknumber

In Javascript object Date there is no native method to get the weeknumber. So you need to extend the Date object.
To get is work in Xpages, put the following code in a Server Side JS scriptlibrary and include this scriptlibrary in the resources of the xpage or custom control:
/**
* Get the ISO week date week number
*/
Date.prototype.getWeek = function () {
// Create a copy of this date object
var target = new Date(this.valueOf());

// ISO week date weeks start on monday
// so correct the day number
var dayNr = (this.getDay() + 6) % 7;

// Set the target to the thursday of this week so the
// target date is in the right year
target.setDate(target.getDate() - dayNr + 3);

// ISO 8601 states that week 1 is the week
// with january 4th in it
var jan4 = new Date(target.getFullYear(), 0, 4);

// Number of days between target date and january 4th
var dayDiff = (target - jan4) / 86400000;

// Calculate week number: Week 1 (january 4th) plus the
// number of weeks between target date and january 4th
var weekNr = 1 + Math.ceil(dayDiff / 7);

return weekNr;
}


Here is an example of how you can use of the getWeek method.
var dt = new Date();
var wk = dt.getWeek();