Fix the date macros to display in the locales's format#33780
Fix the date macros to display in the locales's format#33780Jojo-Schmitz wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis 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)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsLinked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped 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. Comment |
There was a problem hiding this comment.
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 winPlaceholder 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 winPlaceholder 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
📒 Files selected for processing (1)
src/engraving/rendering/score/headerfooterlayout.cpp
157b144 to
a5e7641
Compare
|
Should the date/time format be a(n advanced) preferecnce setting (defaulting to |
f7e1e96 to
24b8618
Compare
24b8618 to
5fc4da5
Compare
There was a problem hiding this comment.
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 | 🟡 MinorAlign header/footer macro formatting + “keep in sync” references for date macros
HeaderFooterLayout::replaceTextMacrosformats$d/$Dand$m/$Musingmuse::DateFormat::LocaleShortFormat.EditStyle::setHeaderFooterMacroInfoTextdocuments$d/$D/$m/$Mbut doesn’t specify a particular date/time format; no otherLocaleShortFormathandling 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 inHeaderFooterLayout::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
📒 Files selected for processing (1)
src/engraving/rendering/score/headerfooterlayout.cpp
Resolves: #15437
Needs musescore/muse_framework#79