Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/engraving/rendering/score/headerfooterlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ TextBlock HeaderFooterLayout::replaceTextMacros(LayoutContext& ctx, const Page*
}

for (size_t i = 0, n = s.size(); i < n; ++i) {
auto dateFormat = muse::DateFormat::LocaleShortFormat;
const char* locale = "de"; // TODO: get the actual locale from the score's style settings
if (!std::setlocale(LC_TIME, locale)) {
LOGW() << "Failed to set LC_TIME locale for language code:" << locale << "using ISO format instead";
dateFormat = muse::DateFormat::ISODate;
}
Char c = s.at(i);
if (c == '$' && (i < (n - 1))) {
Char nc = s.at(i + 1);
Expand Down Expand Up @@ -306,35 +312,33 @@ TextBlock HeaderFooterLayout::replaceTextMacros(LayoutContext& ctx, const Page*
newFragments.back().text += page->score()->masterScore()->fileInfo()->path().toString();
break;
case 'd':
newFragments.back().text += muse::Date::currentDate().toString(muse::DateFormat::ISODate);
newFragments.back().text += muse::Date::currentDate().toString(dateFormat);
break;
case 'D':
{
String creationDate = page->score()->metaTag(u"creationDate");
if (creationDate.isEmpty()) {
newFragments.back().text += page->score()->masterScore()->fileInfo()->birthTime().date().toString(
muse::DateFormat::ISODate);
newFragments.back().text += page->score()->masterScore()->fileInfo()->birthTime().date().toString(dateFormat);
} else {
newFragments.back().text += muse::Date::fromStringISOFormat(creationDate).toString(
muse::DateFormat::ISODate);
newFragments.back().text += muse::Date::fromStringISOFormat(creationDate).toString(dateFormat);
}
}
break;
case 'm': {
IFileInfoProviderPtr fileInfo = page->score()->masterScore()->fileInfo();
if (fileInfo->isNewlyCreated()) {
newFragments.back().text += String(u"HH:mm:ss");
newFragments.back().text += muse::Time::currentTime().toString(dateFormat);
} else {
newFragments.back().text += fileInfo->lastModified().time().toString(muse::DateFormat::ISODate);
newFragments.back().text += fileInfo->lastModified().time().toString(dateFormat);
}
}
break;
case 'M': {
IFileInfoProviderPtr fileInfo = page->score()->masterScore()->fileInfo();
if (fileInfo->isNewlyCreated()) {
newFragments.back().text += String(u"YYYY-MM-DD");
newFragments.back().text += muse::Date::currentDate().toString(dateFormat);
} else {
newFragments.back().text += fileInfo->lastModified().date().toString(muse::DateFormat::ISODate);
newFragments.back().text += fileInfo->lastModified().date().toString(dateFormat);
}
}
break;
Expand Down
Loading