Business Week Day

While translating I found out in the bookmarks reminders this string: “start_of_next_busniess_week”
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/app/controllers/bookmark.js#L264

This can’t work for every country in the world as many countries have Sunday as the start, or any other day.
As per @gerhard suggestion, I’m opening this topic to discuss possible solutions.
The proper solution would be to have a configuration option per user to define the start of the business week, and can have a default of Monday. (And then we would change “Monday” to “Start of Business Week” with a link to the configuration option that appears upon selecting that option).

I though also if the site admin will configure this, but thought that many forums are not country-bound.

Any other thoughts?

5 Likes

Understood, this is a tricky issue for all the countries that start the week on a Sunday. Israel, UAE, Nepal, Malaysia, Saudi and Iran fall in this bucket.

I guess we should consider some sort of setting for “first day of the week”. @martin any ideas of how we should approach this?

Simplest would be just to have a simple way of removing the option, not sure.

3 Likes

Not sure why I didn’t look into this properly when I did this; there is an easy way to get the beginning day of the week in moment.js:

moment().startOf('week').day()

Since we already localize moment, this works great. Just tested it and with my site language set to Hebrew the start of week comes up as 0 (Sunday), whereas if I set it back to English it goes back to 1 (Monday). Should be fairly simple to get this running next week.

If we really wanted to we could have a site-level setting for “start day of week”, not sure if we would want something like that for calendar? Though this probably won’t be desirable when users can set their own locale.

3 Likes

I think it should be a user option. Detecting it by language might not be enough as the start of the week varies by county. Furthermore, not every site enables the user locale setting. Maybe use momentjs to preselect the value like we do with timezone?

3 Likes

Fair enough; I will make it a user option with sane default selection same as timezone!

3 Likes

Great.

And as a side note, language is different than locale as I might be in UK but use the site in Arabic.
This is also something systems take into consideration as they have separate options for locale and UI language.

This mainly affects date, time and numbers, which I’ll open another topic to discuss and see if there is a real need to change it (as it affects many many parts of Discourse).

4 Likes