Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: BackInTheSandbox on October 30, 2019, 08:41:02 am

Title: Variable Expansion - Different Format for $(TODAY)
Post by: BackInTheSandbox on October 30, 2019, 08:41:02 am
Hello,
Is there a way change the format of the $(TODAY) from YYYY-MM-DD to DD.MM.YYYY? The background is that I'm now working for a German company doing coding on an existing codebase. I'm using abbreviations (CTRL-J) very much. But for any documentation about changes I enter dates manually, because I don't want to introduce a different date format in code where a another one is used extensively.

I guess that currently changing the format is not possible. So I'd like to suggest this a new feature. Is this the right forum for that or should I post my suggestion in one of the developer forums?

TIA
Title: Re: Variable Expansion - Different Format for $(TODAY)
Post by: Miguel Gimenez on October 30, 2019, 09:12:15 am
Probably the best way is posting a feature request (or a patch) in a ticket:

https://sourceforge.net/p/codeblocks/tickets/

IMHO the easiest approach is creating a new variable, p.e. TODAY_EU, giving the output you want.
Title: Re: Variable Expansion - Different Format for $(TODAY)
Post by: BackInTheSandbox on October 30, 2019, 09:21:38 am
Thanks for the suggestion. I'll work on that.
Title: Re: Variable Expansion - Different Format for $(TODAY)
Post by: Miguel Gimenez on October 30, 2019, 11:36:52 am
If you are able to recompile C::B then just change line 436 of macrosmanager.cpp from

Code
m_Macros[_T("TODAY")]       = now.Format(_T("%Y-%m-%d"));

to

Code
m_Macros[_T("TODAY")]       = now.Format(_T("%d.%m.%Y"));

or add this line

Code
m_Macros[_T("TODAY_EU")]    = now.Format(_T("%d.%m.%Y"));

EDIT: (hack) you can also edit codeblocks.dll (with HxD, for example) and change the %Y-%m-%d string (search in Unicode) after TODAY to %d.%m.%Y
Title: Re: Variable Expansion - Different Format for $(TODAY)
Post by: BlueHazzard on October 30, 2019, 12:07:18 pm
EDIT: (hack) you can also edit codeblocks.dll (with HxD, for example) and change the %Y-%m-%d string (search in Unicode) after TODAY to %d.%m.%Y
;D

Ii think we should add a global squirrel function that gets a formatter string and returns now.Format(formatter)... I think this is quite handy...
Title: Re: Variable Expansion - Different Format for $(TODAY)
Post by: BackInTheSandbox on October 30, 2019, 09:21:44 pm
EDIT: (hack) you can also edit codeblocks.dll (with HxD, for example) and change the %Y-%m-%d string (search in Unicode) after TODAY to %d.%m.%Y

That hack works, but you need to change the string before TODAY.
Thanks for the tip.