Author Topic: Variable Expansion - Different Format for $(TODAY)  (Read 293 times)

Offline BackInTheSandbox

  • Single posting newcomer
  • *
  • Posts: 4
Variable Expansion - Different Format for $(TODAY)
« 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

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 369
Re: Variable Expansion - Different Format for $(TODAY)
« Reply #1 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.

Offline BackInTheSandbox

  • Single posting newcomer
  • *
  • Posts: 4
Re: Variable Expansion - Different Format for $(TODAY)
« Reply #2 on: October 30, 2019, 09:21:38 am »
Thanks for the suggestion. I'll work on that.

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 369
Re: Variable Expansion - Different Format for $(TODAY)
« Reply #3 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: [Select]
m_Macros[_T("TODAY")]       = now.Format(_T("%Y-%m-%d"));
to

Code: [Select]
m_Macros[_T("TODAY")]       = now.Format(_T("%d.%m.%Y"));
or add this line

Code: [Select]
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
« Last Edit: October 30, 2019, 11:50:52 am by Miguel Gimenez »

Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2545
Re: Variable Expansion - Different Format for $(TODAY)
« Reply #4 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...

Offline BackInTheSandbox

  • Single posting newcomer
  • *
  • Posts: 4
Re: Variable Expansion - Different Format for $(TODAY)
« Reply #5 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.