Menu

#523 Add ${__YEAR__} predefined macro

2.0 Series
wont-fix
nobody
None
5
2014-05-13
2014-05-06
No

It would expand to the current year (4 digit), would be useful for dynamic copyright strings such as:
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${U+00A9}${__YEAR__}, My Company. All rights reserved."

Discussion

  • Anders

    Anders - 2014-05-06
    !define /date __YEAR__ "%Y"
    
     

    Last edit: Anders 2014-05-06
    • Marius Negrutiu

      Marius Negrutiu - 2014-05-07

      This is exactly what I was looking for.
      Thanks!

       
  • Anders

    Anders - 2014-05-06

    If we added a date define in a fixed format you could get the year from that:

    ; ISO 8601 basic:
    !define /redef __UTCDATE__ 20140506
    !define /redef __UTCTIME__ 240560
    !define /math __UTCYEAR__ ${__UTCDATE__} / 10000
    !define /math __UTCMONTH__ ${__UTCDATE__} / 100
    !define /math __UTCDAY__ ${__UTCDATE__} - ${__UTCMONTH__}00
    !define /redef /math __UTCMONTH__ ${__UTCMONTH__} - ${__UTCYEAR__}00
    !define /math __UTCTIMEH__ ${__UTCTIME__} / 10000
    !define /math __UTCTIMEM__ ${__UTCTIME__} / 100
    !define /math __UTCTIMES__ ${__UTCTIME__} - ${__UTCTIMEM__}00
    !define /redef /math __UTCTIMEM__ ${__UTCTIMEM__} - ${__UTCTIMEH__}00
    !echo 'Y=${__UTCYEAR__} M=${__UTCMONTH__} D=${__UTCDAY__} H=${__UTCTIMEH__} M=${__UTCTIMEM__} S=${__UTCTIMES__} (No leading zeros)'
    
    ; ISO 8601 extended:
    !define /redef __UTCDATE__ 2014-05-06
    !define /redef __UTCTIME__ 24:05:60
    !searchparse "!${__UTCDATE__}" "!" __UTCYEAR__ "-" __UTCMONTH__ "-" __UTCDAY__
    !searchparse "!${__UTCTIME__}" "!" __UTCTIMEH__ ":" __UTCTIMEM__ ":" __UTCTIMES__
    !echo 'Y=${__UTCYEAR__} M=${__UTCMONTH__} D=${__UTCDAY__} H=${__UTCTIMEH__} M=${__UTCTIMEM__} S=${__UTCTIMES__} (Leading zeros)'
    

    ...the year is easy to extract in both formats, the rest is a bit of work in the basic format unless we add a /substr mode to !define.

     
  • Anders

    Anders - 2014-05-13
    • status: open --> wont-fix
     

Log in to post a comment.