Skip to content

Fix the date macros to display in the locales's format#33780

Open
Jojo-Schmitz wants to merge 1 commit into
musescore:mainfrom
Jojo-Schmitz:date-macros
Open

Fix the date macros to display in the locales's format#33780
Jojo-Schmitz wants to merge 1 commit into
musescore:mainfrom
Jojo-Schmitz:date-macros

Conversation

@Jojo-Schmitz

@Jojo-Schmitz Jojo-Schmitz commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR changes HeaderFooterLayout::replaceTextMacros to format timestamp macros using muse::DateFormat::LocaleShortFormat. The macros $d (current date), $D (creation date), $m (last modification time), and $M (last modification date) now use LocaleShortFormat; $m/$M "newly created" branches use muse::Time::currentTime()/muse::Date::currentDate() formatted with LocaleShortFormat.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete, missing most required template sections including CLA sign-off, detailed explanation, and testing verification checklist items. Complete the PR description template by adding CLA sign-off, detailed motivation, and filling out all checklist items to document testing and code review readiness.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: converting date macros from ISO format to locale-specific format.
Linked Issues check ✅ Passed The code changes successfully implement locale-aware date formatting for $d, $D, $m, $M macros using LocaleShortFormat, directly addressing issue #15437's requirement to display dates per locale.
Out of Scope Changes check ✅ Passed All code changes are scoped to date macro formatting in HeaderFooterLayout, directly related to the linked issue with no extraneous modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped musescore/muse_framework.git.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/engraving/rendering/score/headerfooterlayout.cpp (2)

323-330: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Placeholder string format inconsistency with locale format.

For newly created files, the placeholder "HH:mm:ss" (line 326) uses an ISO-like format, but after saving, the macro displays time in locale format (line 328). This creates a visual inconsistency where the format changes after the first save.

Consider using a locale-appropriate placeholder or a generic string like "--:--:--" to avoid implying a specific format.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engraving/rendering/score/headerfooterlayout.cpp` around lines 323 - 330,
The placeholder in the case 'm' branch uses a hardcoded "HH:mm:ss" for newly
created files while saved files use
fileInfo->lastModified().time().toString(muse::DateFormat::LocaleShortFormat),
causing a format mismatch; change the newFragments.back().text assignment in the
case 'm' block (where fileInfo->isNewlyCreated() is checked) to use a
locale-appropriate placeholder (e.g. produce a localized empty-time
representation by formatting a sentinel time with DateFormat::LocaleShortFormat
or use a neutral placeholder like "--:--:--") so the displayed format for newly
created files matches the locale-based format used after saving.

332-339: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Placeholder string format inconsistency with locale format.

For newly created files, the placeholder "YYYY-MM-DD" (line 335) uses an ISO format, but after saving, the macro displays the date in locale format (line 337). This creates a visual inconsistency where the format changes after the first save.

Consider using a locale-appropriate placeholder or a generic string like "-----..--" to avoid implying a specific format.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engraving/rendering/score/headerfooterlayout.cpp` around lines 332 - 339,
In case 'M' inside headerfooterlayout.cpp where newFragments.back().text is set,
avoid hardcoding the ISO placeholder "YYYY-MM-DD" when
fileInfo->isNewlyCreated(); instead append a locale-consistent placeholder (or
the same formatted string used for saved files) so the displayed format does not
change after save — e.g., replace the literal with a locale-aware placeholder
generated the same way as
fileInfo->lastModified().date().toString(muse::DateFormat::LocaleShortFormat) or
use a neutral placeholder like "-----..--" so the UI remains consistent; update
the code around fileInfo->isNewlyCreated() and the case 'M' block accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/engraving/rendering/score/headerfooterlayout.cpp`:
- Around line 323-330: The placeholder in the case 'm' branch uses a hardcoded
"HH:mm:ss" for newly created files while saved files use
fileInfo->lastModified().time().toString(muse::DateFormat::LocaleShortFormat),
causing a format mismatch; change the newFragments.back().text assignment in the
case 'm' block (where fileInfo->isNewlyCreated() is checked) to use a
locale-appropriate placeholder (e.g. produce a localized empty-time
representation by formatting a sentinel time with DateFormat::LocaleShortFormat
or use a neutral placeholder like "--:--:--") so the displayed format for newly
created files matches the locale-based format used after saving.
- Around line 332-339: In case 'M' inside headerfooterlayout.cpp where
newFragments.back().text is set, avoid hardcoding the ISO placeholder
"YYYY-MM-DD" when fileInfo->isNewlyCreated(); instead append a locale-consistent
placeholder (or the same formatted string used for saved files) so the displayed
format does not change after save — e.g., replace the literal with a
locale-aware placeholder generated the same way as
fileInfo->lastModified().date().toString(muse::DateFormat::LocaleShortFormat) or
use a neutral placeholder like "-----..--" so the UI remains consistent; update
the code around fileInfo->isNewlyCreated() and the case 'M' block accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7382387b-a243-43b3-91fd-32d610fba3d1

📥 Commits

Reviewing files that changed from the base of the PR and between aa38811 and 157b144.

📒 Files selected for processing (1)
  • src/engraving/rendering/score/headerfooterlayout.cpp

@Jojo-Schmitz

Jojo-Schmitz commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Should the date/time format be a(n advanced) preferecnce setting (defaulting to ISODate, to make sure it is that on musescore.com)?
Or is there some preprocessor define that tells the backend build from other builds?
Or would that need something to get sorted on the muse_framework end (rather than relying on LC_TIME being set properly on the backend)?

@Jojo-Schmitz Jojo-Schmitz force-pushed the date-macros branch 2 times, most recently from f7e1e96 to 24b8618 Compare June 11, 2026 22:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/engraving/rendering/score/headerfooterlayout.cpp (1)

213-246: ⚠️ Potential issue | 🟡 Minor

Align header/footer macro formatting + “keep in sync” references for date macros

  • HeaderFooterLayout::replaceTextMacros formats $d/$D and $m/$M using muse::DateFormat::LocaleShortFormat.
  • EditStyle::setHeaderFooterMacroInfoText documents $d/$D/$m/$M but doesn’t specify a particular date/time format; no other LocaleShortFormat handling for these macros was found, so preview/render inconsistencies from formatting are unlikely.
  • The tooltip comment still says “keep in sync with implementation in Page::replaceTextMacros (page.cpp)”, but the actual macro implementation is in HeaderFooterLayout::replaceTextMacros—update the comment to avoid future drift.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engraving/rendering/score/headerfooterlayout.cpp` around lines 213 - 246,
The header/footer macro handling and its doc comment are out of sync: update the
tooltip/comment that currently references Page::replaceTextMacros to point to
HeaderFooterLayout::replaceTextMacros, and document that date/time macros $d/$D
and $m/$M are formatted using muse::DateFormat::LocaleShortFormat so
EditStyle::setHeaderFooterMacroInfoText (or its tooltip text) matches the actual
formatting; modify the comment block above HeaderFooterLayout::replaceTextMacros
to say “keep in sync with toolTipHeaderFooter in
EditStyle::EditStyle()/setHeaderFooterMacroInfoText” (or similar) and add a
short note that $d/$D and $m/$M use LocaleShortFormat to avoid future drift
between implementation and documentation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/engraving/rendering/score/headerfooterlayout.cpp`:
- Around line 213-246: The header/footer macro handling and its doc comment are
out of sync: update the tooltip/comment that currently references
Page::replaceTextMacros to point to HeaderFooterLayout::replaceTextMacros, and
document that date/time macros $d/$D and $m/$M are formatted using
muse::DateFormat::LocaleShortFormat so EditStyle::setHeaderFooterMacroInfoText
(or its tooltip text) matches the actual formatting; modify the comment block
above HeaderFooterLayout::replaceTextMacros to say “keep in sync with
toolTipHeaderFooter in EditStyle::EditStyle()/setHeaderFooterMacroInfoText” (or
similar) and add a short note that $d/$D and $m/$M use LocaleShortFormat to
avoid future drift between implementation and documentation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f986b142-61c6-40e3-b5bd-fa2d2dd22a3a

📥 Commits

Reviewing files that changed from the base of the PR and between 24b8618 and 5fc4da5.

📒 Files selected for processing (1)
  • src/engraving/rendering/score/headerfooterlayout.cpp

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.

The date macros ($d, $D, $M) for header/footer show the dates in ISO format (YYYYY-MM-DD) rather than as per the current locale

2 participants