[#13655] add windows platform support in dynamic calendar view
Summary add windows platform support in dynamic calendar view
Queue Kronolith
Queue Version 4.2.2
Type Bug
State Assigned
Priority 1. Low
Owners Horde Developers
Requester evb@ping.be
Created 2014-10-30 (2586 days ago)
Updated 2016-04-11 (2057 days ago)
Assigned 2016-01-22 (2137 days ago)
Patch No

evb@ping.be 2014-10-30 18:19:10
The text below is a copy of the mailing traffic:
For some time now I can't edit or add events in the dynamic view. No
  problem in editing or adding in the simple view!

  So I did some debug in FireBug and the reason is a undefined
  'date_format' in the javascript file kronolith.js, function getDate:
    getDate: function(what) {
        var dateElm, timeElm, date, time;
        if (what == 'start') {
            dateElm = 'kronolithEventStartDate';
            timeElm = 'kronolithEventStartTime';
        } else {
            dateElm = 'kronolithEventEndDate';
            timeElm = 'kronolithEventEndTime';
        date = Date.parseExact($F(dateElm), Kronolith.conf.date_format)
            || Date.parse($F(dateElm));
        if (date) {
            time = Date.parseExact($F(timeElm),
            if (!time) {
                time = Date.parse($F(timeElm));
            if (time) {
        return date;

  Kronolith.conf.date_format is for some reason undefined.
  When I look via FireBug into the object 'Kronolith' I see two child
  objects 'conf' and 'text'. In the child object 'conf' I see a
  defined 'time_format', but no 'date_format'.
  When I define via FireBug a 'date_format', everything is working, I
  can add and edit events in the dynamic view!


I found two problems under windows causing the above described problems:
  1. the php function nl_langinfo is used, but this function isn't
  implemented on windows platforms
  2. the php function setlocale is used, but the locale strings used are
  not the same on windows platforms

  For the first problem a workaround exists by simulating the missing
  function. Paul Kemper did write a 'windows' nl_langinfo function. This
  function is too long to include here, but I can send it if requested.
  There was still a bug in his function for the D_FMT locale and
  strftime parameter '%e'. The latter isn't implemented on windows, so
  it must be replaced by '%#d'.
  And because of this the function translateFormat in Datejs.php
  (C:\php\pear\Horde\Core\Script\Package\Datejs.php) must be adapted for
  the '%e' translation, no leading space on windows:
        * Translates date format strings from strftime to datejs.
        * @param string $format  A date format string in strftime syntax.
        * @return string  The date format string in datejs format.
       static public function translateFormat($format)
           $from = array('%e', '%-d', '%d', '%a', '%A', '%-m', '%m',
  '%h', '%b', '%B', '%y', '%Y');
           $to = array('d', 'd', 'dd', 'ddd', 'dddd', 'M', 'MM', 'MMM',
  'MMM', 'MMMM', 'yy', 'yyyy');
           if (defined('D_FMT')) {
               $from[] = '%x';
               $to[] = str_replace($from, $to, Horde_Nls::getLangInfo(D_FMT));
           return str_replace($from, $to, $format);

  Add the simulated function nl_langinfo as an include in the Nls.php
  file (C:\php\pear\Horde\Nls.php):
  include( 'WindowsNl_LangInfo.php' );

  For the second problem, I first created a new nls.local.php
  configuration file (C:\Apache24\htdocs\webmail\config\nls.local.php)
  with the windows locales strings:
           'usa_usa' => '‭English (American)',
           'uk_uk' => '‭English (British)',
           'canadian_can' => '‭English (Canadian)',
           'fra_fra' => 'Français',
           'nld_nld' => 'Nederlands'
  And then modified the function setLanguage in Registry.php
  (C:\php\pear\Horde\Registry.php) to not include 'UTF-8', also not
  supported on each windows platform.
  But that didn't work, I'm missing something I think.
  If I hard code the wanted language 'nld_nld' in the function
  setLanguage, then it works. Of course the user can't change the
  language anymore. That's not a problem for me, but as generic
  solution, this can't be coded like this!

  With all these changes the agenda is now working in the wanted
  language, I can now add events, delete and change events.
  But it is not future proof, the next upgrade of horde will delete the
  changes and I'm back at the beginning.
  The key question is, will horde support an installation on windows in
  the future? For this to happen, the code must be made cross-platform...

Jan Schneider <jan@horde.org> 2016-01-22 11:16:26
It's time to review a Window install. Haven't used PHP or Horde on 
Windows since ages.

niels@schoot.com 2016-04-11 21:05:11
Attached file implements the nl_langinfo() function (All credits to 
Paul Kemper, source: 
It's in Dutch. I took the most correct (latest) version. )

I included this file in Nls.php (as suggested) so function_exists in 
getLangInfo() is now true and this function now returns something 
useful rather than False. This solves the problem and it's now 
possible to create new calendar items in dynamic view.