Skip to content

Signup field calculation: time zone fixes from ctsms #579 - #60

Merged
rkrenn merged 3 commits into
masterfrom
timezones
Nov 30, 2026
Merged

rkrenn merged 3 commits into
masterfrom
timezones

Conversation

@rkrenn

@rkrenn rkrenn commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Ports the field calculation time zone fixes of phoenixctms/ctsms#579 to the Signup copy of fieldCalculation.js and regenerates fieldCalculation.min.js (minify.pl).

  • A text or LocalDateTime value set on a timestamp field with "user time zone" is read in the input time zone (the site's time zone), not the system time zone. Example: system UTC, site Europe/Vienna, a calculation sets "01.05.2026 10:00": it was taken as 10:00 UTC (shown as 12:00 Vienna), now it is 10:00 Vienna.
  • A javascript Date set on a timestamp field is taken as the instant it is. Before, the browser's local wall clock was taken as system time zone time: browser Vienna, system UTC, new Date() at 10:00Z became 12:00Z.

The changed lines are the same as in the ctsms web copy.

Also: without convert_timezone (the default), the inquiry page passed values of user time zone timestamp fields to the field calculation as site wall clock times (Signup loads them with ?tz=<site time zone>), while the field calculation reads timestamps in the system time zone. System UTC, site Europe/Vienna: a value of 08:00 Vienna was taken as 08:00 UTC and shown as 10:00. datetime_ui_to_json (used only for these JS rows) now converts user time zone values from the site time zone to the system time zone in both modes. Saving (datetime_ui_to_iso) is unchanged, since ctsms converts by tz there. Otherwise Signup already sends date and time field values as system time zone strings, and ctsms#579 now reads them in the system time zone also with ?tz= (before, each save moved them by the site's offset). The same applies to the eCRF/inquiry importers with a timezone setting.

Tested:

  • The new Date conversion with the same js-joda build in Nashorn (JVM zone Europe/Vienna): 10:00Z stays 10:00Z, the old code gave 12:00Z. The minified file contains both changes.
  • On the ctsms test VM (system UTC): a user time zone timestamp inquiry value saved with tz=Europe/Vienna as 08:00 is stored as 06:00 UTC and returned in the page values as 2026-05-01 08:00:00. Signup's datetime_iso_to_ui + datetime_ui_to_json with a Vienna site turn it into 2026-05-01 06:00 (before: 08:00) with convert_timezone off and on; fields without user time zone are unchanged.
  • Signup in headless Edge on the VM (Signup system_timezone UTC like ctsms there, site time zone Europe/Vienna, convert_timezone off): registered a proband (birth date 01.05.1990 stored as 1990-05-01), opened a trial questionnaire with a user time zone timestamp inquiry tsu (value 08:00 Vienna = 06:00 UTC) and a text inquiry calculated by function(tsu) { return tsu.toString(); }. Applying the calculated value gives 2026-05-01T06:00Z[UTC]; with the previous Utils.pm it gave 2026-05-01T08:00Z[UTC]. Changing the time to 09:00 in the form and saving stored 07:00 UTC.

Needs phoenixctms/ctsms#579.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved timestamp handling to respect the field’s configured time zone when applicable.
    • Date values are now interpreted consistently across browsers, avoiding unintended shifts caused by local time settings.

… #579): a text or LocalDateTime timestamp set on a user time zone field is read in the input time zone (it was read in the system time zone), and a javascript Date set on a timestamp field is taken as the instant it is (it took the browser's wall clock as system time zone time). fieldCalculation.min.js regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b73e7bee-07f1-4f2b-9ee2-49eb52468a14
Commits

Reviewing files that changed from the base of the PR and between e12fa30 and 269e9c6.

Files ignored due to path filters: 1

  • CTSMS/BulkProcessor/Projects/WebApps/Signup/public/js/fieldcalculation/fieldCalculation.min.js is excluded by !**/*.min.js
Files selected for processing: 2

  • CTSMS/BulkProcessor/Projects/WebApps/Signup/Utils.pm
  • CTSMS/BulkProcessor/Projects/WebApps/Signup/public/js/fieldcalculation/fieldCalculation.js

No actionable comments were generated in the recent review.

Walkthrough

Timestamp assignments now select a timezone based on the userTimeZone flag for strings and LocalDateTime values. JavaScript Date values use epoch milliseconds for assignment and sanitization.

Changes: Timestamp conversion

Layer / File(s) Summary
Timestamp assignment and sanitization
CTSMS/BulkProcessor/Projects/WebApps/Signup/public/js/fieldcalculation/fieldCalculation.js
String and LocalDateTime assignments use the input timezone when userTimeZone is true, and the system timezone otherwise. Date values use epoch milliseconds for assignment and sanitization; sanitization retains system-zone handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · previous review e12fa · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "Signup field calculation: time zone fixes from ctsms #579" matches the main change. The PR changes fieldCalculation.js so timestamp fields use the user or system time zone correctly and tre…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "Signup field calculation: time zone fixes from ctsms #579" matches the main change. The PR changes fieldCalculation.js so timestamp fields use the user or system time zone correctly and treat JavaScript Date inputs as instants. The title names the affected component (Signup field calculation) and the nature of the change (time zone fixes). It also references the upstream source (ctsms #579). It is specific enough for a teammate to understand the primary change, though it does not name the Date-handling fix explicitly.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8127b136-2109-4cc0-aed8-ba46c3cbfe29
Commits

Reviewing files that changed from the base of the PR and between 38087aa and e12fa30.

Files ignored due to path filters: 1

  • CTSMS/BulkProcessor/Projects/WebApps/Signup/public/js/fieldcalculation/fieldCalculation.min.js is excluded by !**/*.min.js
Files selected for processing: 1

  • CTSMS/BulkProcessor/Projects/WebApps/Signup/public/js/fieldcalculation/fieldCalculation.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

rkrenn and others added 2 commits November 30, 2026 14:32
…fields are passed in the system time zone also without convert_timezone. Signup then loads them with ?tz=<site time zone>, so they arrived as site wall clock times and the field calculation, which reads timestamps in the system time zone, was off by the site's offset (system UTC, site Europe/Vienna: 08:00 Vienna was taken as 08:00 UTC and shown as 10:00).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion are kept in the system time zone, so an unchanged user time zone timestamp is no longer marked as changed (ZonedDateTime.equals compares the zone). fieldCalculation.min.js regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rkrenn
rkrenn merged commit 504a80b into master Nov 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant