Rounddatetime('week') ignores time zone and varies with user language settings

I have encountered an issue with the rounddatetime() function when using the “week” unit in Tulip apps. The behavior changes depending on the user’s language settings, which leads to inconsistent results.

To reproduce, I use a fixed datetime (for example May 15, 2026) and apply the following expressions:

  • rounddatetime(@Variable.startdate, ‘week’)

  • rounddatetime(@Variable.startdate, ‘week’, ‘Europe/Stockholm’)

  • rounddatetime(@Variable.startdate, ‘week’, ‘America/New_York’)

When the user language is set to English (both British and American), the function rounds the date to the start of the week on Sunday, resulting in May 10, 2026.

However, when changing the user language to Swedish, the same expressions instead round to Monday, resulting in May 11, 2026.

This means that the start of the week is determined by the user’s language rather than the specified time zone. Even when a time zone is explicitly provided, the result still changes depending on the language setting.

This creates a problem because the same app behaves differently for users with different language settings.

In our current app, we have implemented logic so that the function checks the user’s language and adds a day if it is English, and does nothing if it is Swedish (or shows an error message for unsupported languages). However, this does not feel like an optimal solution, especially if the app is scaled to multiple regions."

(Tulip version is LTS15.6)

Hi,
that’s not an issue but a normal behaviour.

That is why a calendar in the USA often begins with Sunday, in many European countries with Monday, and some countries use Saturday as the first day in their regional settings. None of these variations is incorrect.


Warum die Woche in manchen Ländern am Sonntag und in anderen am Montag beginnt

So I think your solution is the right one

2cents
Chris

I agree, and of course I understand that different regions use different first days of the week. That is not the issue in itself. My point is that it should still be possible to explicitly control which day the week starts on. Having the function’s behavior change based on the user’s language settings feels a bit unpredictable.

A better approach would be if this could be defined by letting the function follow the time zone or locale explicitly provided in the expression. That would make the behavior more consistent and easier to reason about, especially in apps used across multiple regions.

@ChrisF
But do you think, it would be an issue, if this would follow the region of the time-zone (e.g. Berlin), when defined?

If it is relevant for the logic, it can be an issue, if it is controlled by the users language.

When no time zone is set, the users language could be a valid fallback.

Hi all,
I just wanted to start by saying that this isn’t a generell Tulip issue, as the start of the week is based on the region settings.
The region setting/timezone is more important than the language setting, because the language setting, if not precisely defined by language/region, can become an issue and an invalid fallback (America/Canada: English/Spanish/French vs. Spanish/Spain, French/France).

Does anyone in america know that the week begins with monday outside america? :wink:

The solution is not easy to find and a global common solution can results in an (logic) issue.

Therefor I’m very interested in the answer by Tulip, how to handle this.

2cents
Chris

This video will help when dealing with timezones:

The Problem with Time & Timezones - Computerphile