Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds flexible date formatting support for forms and templates.
This introduces
formatDate(value, format, timezone?)for form expressions and HTML questions, using the existing shared AngularDatePipebehavior. It also extends the existing template/widget expression{{calc.date(value ; format)}}to support an optional timezone parameter:{{calc.date(value ; format ; timezone)}}.The default timezone is
UTCwhen no timezone is provided. Invalid or missing date values fail gracefully by rendering an empty value instead of breaking the rendered content.Useful links
Type of change
How Has This Been Tested?
npx nx test shared --testFile=libs/shared/src/lib/utils/custom-functions.spec.tsnpx nx test shared --testFile=libs/shared/src/lib/services/html-parser/html-parser.service.spec.tsnpx nx test shared --testFile=libs/shared/src/lib/services/form-helper/form-helper.service.spec.tsnpx nx lint shared{formatDate({submission_date}, 'dd/MM/yyyy HH:mm', 'UTC')}{{calc.date(2024-11-26T23:00:00.000-05:00 ; dd/MM/yyyy HH:mm ; -0500)}}Screenshots
HTML render:
HTML field markup settings:
<p><strong>Datetime UTC: </strong>{formatDate({submission_date}, 'dd/MM/yyyy HH:mm', 'UTC')}</p><p><strong>Datetime Default: </strong>{formatDate({submission_date}, 'dd/MM/yyyy HH:mm')}</p><p><strong>Datetime ET: </strong>{formatDate({submission_date}, 'dd/MM/yyyy HH:mm', 'ET')}</p><p><strong>Long Format: </strong>{formatDate({submission_date}, 'MMM d, y, h:mm a', 'UTC')}</p><p><strong>Test: </strong>{formatDate('2024-11-26T23:00:00.000-05:00', 'dd/MM/yyyy HH:mm')}</p><p><strong>Test: </strong>{formatDate('2024-11-26T23:00:00.000-05:00', 'dd/MM/yyyy HH:mm', '-0500')}</p>Summary Card widget:
Text Editor:
{{calc.date(2024-11-26T23:00:00.000-05:00 ; dd/MM/yyyy HH:mm ; -0500)}}Checklist:
( * == Mandatory )