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
This commit is contained in:
parent
1988aac2b3
commit
da634a618f
|
@ -98,6 +98,18 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
|
||||||
bool tokenUpdated = false;
|
bool tokenUpdated = false;
|
||||||
wxString originalToken = *aToken;
|
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" ) ) )
|
if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) )
|
||||||
{
|
{
|
||||||
*aToken = GetDate();
|
*aToken = GetDate();
|
||||||
|
@ -105,14 +117,7 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
|
||||||
}
|
}
|
||||||
else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
||||||
{
|
{
|
||||||
// We can choose different formats. Should probably be kept in sync with ISSUE_DATE
|
*aToken = getCurrentDate();
|
||||||
// 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();
|
|
||||||
|
|
||||||
tokenUpdated = true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
|
else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
|
||||||
|
@ -152,7 +157,9 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
|
||||||
|
|
||||||
if( tokenUpdated )
|
if( tokenUpdated )
|
||||||
{
|
{
|
||||||
if( aProject )
|
if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
||||||
|
*aToken = getCurrentDate();
|
||||||
|
else if( aProject )
|
||||||
*aToken = ExpandTextVars( *aToken, aProject );
|
*aToken = ExpandTextVars( *aToken, aProject );
|
||||||
|
|
||||||
// This is the default fallback, so don't claim we resolved it
|
// This is the default fallback, so don't claim we resolved it
|
||||||
|
|
Loading…
Reference in New Issue