Classic Domino and multi country dates with Bootstrap

I was doing some fixes on a classic domino web app that uses bootstrap datepicker when an issue was raised. turns out its a bugger to get the jquery datapicker and domino date format to agree with each other for different countires ie mm/dd/yyyy or dd/mm/yyyy or dd.mm.yyyy

you would think that a little bit of JavaScript would solve the problem but there was multiple instances with a variety of browsers where it ended up that what ever domino was doing to calculate the date format was not matching the result of the JavaScript.

So we cheated, we replaced the “format:” parameter in the date picker below:

$('#MYDATE').datepicker({
    format: "mm/dd/yyyy",
    clearBtn: true,
    orientation: "top auto",
    todayHighlight: true,
    autoclose: true,
    weekStart: 1
 });

with some computed text with the following formula:

dat := @Text(@ToTime("01/28/1900");"D0S0") ;
sep := @Middle(dat ;2;1) ;
@If( @Left(dat; 2) = "28" ; "dd" + sep + "mm" + sep + "yyyy" ; "mm" + sep + "dd" + sep + "yyyy")

I find the best way is to put this in the default setting meaning you only have to do it once

$.datepicker.setDefaults({
     dateFormat: '<Computed Value>'
});

Simple, worked fine with a wide variety of date formats and kept everything in sync with what ever format Domino ended up picking.

Leave a Reply

Your email address will not be published. Required fields are marked *