feat: Add configurable date/time format for Alt+T shortcut #4925
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.
Summary:
This pull request introduces a user-configurable date/time format for the
Alt+T
keyboard shortcut. Users can now define their preferred date and time string format using Day.js tokens via a new setting, providing greater flexibility.Changes Implemented:
Alt+T
command (insertDateTimeToTextCommand
) now attempts to retrieve the custom format string from application options.utils.formatDateTime
function has been updated to usedayjs
with the user-supplied format string.YYYY-MM-DD HH:mm
).How to Test:
DD/MM/YYYY HH:mm:ss
,MMMM D, YYYY
).Alt+T
. The date and time should be inserted using the custom format (assuming the option saved correctly).Alt+T
in a text note. The date and time should revert to the default Trilium format.Note on Saving Options During Testing:
While developing this feature on my Windows 11, I sometimes encountered errors in the console (like "EPERM: operation not permitted" related to session files, followed by "ERR_HTTP_HEADERS_SENT") when trying to save changes in the Options screen. This happened not just with my new setting, but also when changing other existing Trilium options.
It seems like there might be something in my local setup (perhaps related to file access or another program) that occasionally interferes with how Trilium saves options or session data.
The custom date/time formatting feature itself should work correctly if the option saves properly.
Related Issue:
This feature addresses the user need for more flexible date formatting, similar to what was requested in issue #4906.
Closes #4906
Screenshots: