rejetto forum

Converting a date format with macros

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13516
    • View Profile
foggy asked me on how to change the date format from 13/12/2007 to 13-Dec-2007.

This is NOT meant to be a good method, i made it just to have fun and to test macros.
It's good for those who wants to know more on macros.

I created a user-macro called convert date.

Code: [Select]
{{set|convert date| {{\
  {{set|x|{{replace|/|-|$1}} }}
  {{cut|1|3|{{^x}}}}{{!Month{{cut|4|2|{{^x}} }} }}{{cut|6||{{^x}}}}
/}} }}

{{^convert date|13/12/2007}}

[special:strings]
Month01=Jan
Month02=Feb
Month03=Mar
Month04=Apr
.....
Month11=Nov
Month12=Dec


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13516
    • View Profile
for those of you who enjoy fucking their own brain, the following is a sample of how you can get things in many ways.
foggy was waiting for the macro ">" that was introduced in the last version.
i wondered if it could be done with existing macros.
i didn't come to (and i won't try more because i'm tired) a real answer because i got the ">" by using "max" and "sub", and "sub" was introduced in the last beta as well, but i think this may be fun for someone.

{{>|A|B}} is equivalent to {{max| {{sub|A|B}} |0}}

explanation
case "false": when A is equal or less than B, the sub will be 0 or negative. the max between a number that is 0 or less, and zero, is of course zero, that is false in the macro language.
case "true": when A is greater than B, the sub will be 1 or more. the max between a number that is 1 or more, and zero, is of course the "1 or more", that is true in macro language.

i hope this was fun and/or useful for someone.


Offline Giant Eagle

  • Tireless poster
  • ****
    • Posts: 535
  • >=3 RAWR!
    • View Profile
    • RAWR-Designs.com
My brain hurts..

..but i'm still laughing :P


Macro's are really becoming something great now.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Hey yes, it is going to need for some people  that they take the road of the school