Resolve double-indirection CURRENT_DATE in title blocks.

If ${COMMENT1} resolves to ${CURRENT_DATE} then we need to resolve again.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17256

(cherry picked from commit da634a618f)
This commit is contained in:
Jeff Young 2024-03-05 13:34:46 +00:00
parent 357226eb71
commit 45e17307a1
1 changed files with 16 additions and 9 deletions

View File

@ -98,6 +98,18 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
bool tokenUpdated = false;
wxString originalToken = *aToken;
auto getCurrentDate =
[]() -> wxString
{
// We can choose different formats. Should probably be kept in sync with ISSUE_DATE
// formatting in DIALOG_PAGES_SETTINGS.
//
// return wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
// return wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
// return wxDateTime::Now().Format( wxT("%Y-%b-%d") );
return wxDateTime::Now().FormatISODate();
};
if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) )
{
*aToken = GetDate();
@ -105,14 +117,7 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
}
else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
{
// We can choose different formats. Should probably be kept in sync with ISSUE_DATE
// formatting in DIALOG_PAGES_SETTINGS.
//
// *aToken = wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
// *aToken = wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
// *aToken = wxDateTime::Now().Format( wxT("%Y-%b-%d") );
*aToken = wxDateTime::Now().FormatISODate();
*aToken = getCurrentDate();
tokenUpdated = true;
}
else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
@ -152,7 +157,9 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
if( tokenUpdated )
{
if( aProject )
if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
*aToken = getCurrentDate();
else if( aProject )
*aToken = ExpandTextVars( *aToken, aProject );
// This is the default fallback, so don't claim we resolved it