meeting-room-booking-system / mrbs-code

MRBS application code
Other
124 stars 61 forks source link

Week numbers show differently in week view and in mini calendar #3515

Open Langveisfra opened 1 year ago

Langveisfra commented 1 year ago

The week view and the mini calendar do not show the same week number. The desired week number is according to the ISO 8601 that gives week number 1 to the first week of year that contains a Thursday.

The mini calendar shows the right number, the week view does not. Here are the relevant variables of my config.inc.php-file: $view_week_number = true; $mincals_week_numbers = true; $weekstarts = 1;

I run MRBS v. 1.11.3 image

campbell-m commented 1 year ago

I'm struggling to reproduce this. When the fault happens can you say please

  1. What the page_date is in the query string?
  2. What timezone your area is set to?
  3. What timezone your PC is set to?
campbell-m commented 1 year ago

One more question:

  1. What extensions do you have enabled on your PHP system? The answer is on the MRBS Help page under "Utvidelser", when logged in as an admin.
Langveisfra commented 1 year ago
  1. 2023-10-16 (as in the example from my posting)
  2. Oslo
  3. Oslo
  4. Core, FFI, PDO, PDO_ODBC, Phar, Reflection, SPL, SimpleXML, Zend OPcache, bcmath, bz2, calendar, ctype, curl, date, dba, dom, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imagick, imap, intl, json, ldap, libxml, mbstring, mongodb, mysqli, mysqlnd, odbc, openssl, pcntl, pcre, pdo_dblib, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, posix, pspell, random, readline, session, shmop, soap, sockets, sodium, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uwsgi, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib
campbell-m commented 1 year ago

Thanks. Does this happen on standard MRBS 1.11.3, or have you made any changes to the MRBS code?

Langveisfra commented 1 year ago

The 1.11.3 is taken from det dev source one week ago. I can also put up a standard 1.11.3. I'll post you the address in 15 minutes.

Langveisfra commented 1 year ago

A clean 1.11.3 install gives the same result.

campbell-m commented 1 year ago

Thanks. What version of PHP are you running?

Langveisfra commented 1 year ago

8.2.10 (A test server with 8.2.5 gives the same result)

Langveisfra commented 1 year ago

Another finding:      $view_week_number = true;      $mincals_weeknumbers = false; -hides week numbers both in mini calendar and in main calendar_

$view_week_number = false;
$mincals_week_numbers = true;

-hides week numbers in mini calendar, but shows week numbers in main calendar (but wrong week number).

Is it possible to let week numbers just show up in mini calendar (as they are displayed correctly here), and not in the main calendar (main mindow - week view, where they are not displaying correctly)?

campbell-m commented 1 year ago

Could you run the attached test program please on your server (you'll need to unzip it first) and post the output? The output should look something like

PHP version: 8.3.0RC2
System: Windows NT SNOWDROP 10.0 build 22621 (Windows 11) AMD64
Server: Microsoft-IIS/10.0
Date (strftime): 2023-09-22
Week (strftime): 38
Week (intl) (nb): 38
Week (intl) (nn): 38
Week (intl) (no): 38

test_week.zip

campbell-m commented 1 year ago

Is it possible to let week numbers just show up in mini calendar (as they are displayed correctly here), and not in the main calendar (main mindow - week view, where they are not displaying correctly)?

Now fixed in 2b3f038.

Langveisfra commented 1 year ago

Could you run the attached test program please on your server (you'll need to unzip it first) and post the output? The output should look something like

PHP version: 8.3.0RC2
System: Windows NT SNOWDROP 10.0 build 22621 (Windows 11) AMD64
Server: Microsoft-IIS/10.0
Date (strftime): 2023-09-22
Week (strftime): 38
Week (intl) (nb): 38
Week (intl) (nn): 38
Week (intl) (no): 38

test_week.zip

Here is the output:

PHP version: 8.2.10 System: Linux ws36 5.4.0-163-generic #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 2023 x86_64 Server: Apache/2.4.41 Date (strftime): 2023-09-22 Week (strftime): 38 Week (intl) (nb): 38 Week (intl) (nn): 38 Week (intl) (no): 38

campbell-m commented 1 year ago

Thanks. Could you try the attached version of index.php please and see if it fixes the problem?

index.zip

Langveisfra commented 1 year ago

Thank you for your effort! Unfortunately, it did not solve the problem. Tested on 1.11.2 and 1.11.3.

campbell-m commented 1 year ago

Here's another version of index.php. This time it's a diagnostic version and should give output like

2023-9-22 (1695340800) Uke 38 | 18. - 24. september 202

Can you let me know what it says on your system?

index.zip

Langveisfra commented 1 year ago

2023-9-22 (1695376800) Uke 39 | 18. - 24. september 2023 (both 1.11.2/1.11.3)

campbell-m commented 1 year ago

And in addition could you use this diagnostic version of lib/IntlDateFormatter.php please? You should get output like

2023-9-23 (1695427200) Uke %J:38 | %i.:18. - %i. %B %Y:24. september 2023

IntlDateFormatter.zip

Langveisfra commented 1 year ago

Replaced the lib/IntlDateFormatter.php with the file posted above. No difference in the main calendar. 2023-9-22 (1695376800) Uke 39 | 18. - 24. september 2023

Should the output appear somewhere else? image

campbell-m commented 1 year ago

OK, that's fine. Thanks. It's actually what I'd expect.

campbell-m commented 1 year ago

And can you use the attached version of language.inc? The output should look like

2023-9-23 (1695463200) Uke (nb)38 | (nb)18. - (nb)24. september 2023

language.zip

Langveisfra commented 1 year ago

2023-9-22 (1695376800) Uke (no-NB)39 | (no-NB)18. - (no-NB)24. september 2023

campbell-m commented 1 year ago

Ah! Can you set

$override_locale = 'nb-NO';  // or just 'nb'

nb is the language and NO is the country (in this case), so you have them in the wrong order. I think that will solve the problem.

(Or you could just not set $override_locale locale at all and use the browser's language preferences).

Langveisfra commented 1 year ago

Oh - that was sloppy of me. It did the trick. Campbell for president! :-)

campbell-m commented 1 year ago

Good, glad it's working. I'm not sure why PHP was behaving this way though, even with an invalid locale. I have raised an issue on PHP.

Langveisfra commented 1 year ago

$faqfilelang = "no"; $override_locale = "nb-NO"; gives correct week numbers, but day names of the mini-calendar shows up in nynorsk ("nn-NO")

$disable_automatic_language_changing = true; $default_language_tokens = "no"; on the other hand gives right weeknumbers and day names in bokmål ("nb-NO")

image
campbell-m commented 1 year ago

I've raised this as a separate issue at #3517 .

campbell-m commented 1 year ago

I have reopened this issue as a reminder to fix the week number problem properly. MRBS should not allow an invalid locale to be passed to IntlDateFormatter::construct.