Template talk:Days Left

(Redirected from Template talk:Days Left/sandbox)
Latest comment: 1 year ago by FeRDNYC in topic Enhanced sandbox version

Example edit

There are {{Days Left|day=31 |month=12 |year=2024}} days left for [[New Year]].
There are 212 days left for New Year.

- Yasir72.multan Talk Contribs
16:24, 4 February 2016 (UTC)Reply

Enhanced sandbox version edit

I have a version of this template in the sandbox that (IMHO) improves over the current version in a few ways (the second one pretty meaningless):

  1. It allows the user to pass an unnamed parameter containing an entire date string (in any format #time: supports), instead of setting |day=, |month=, |year= separately. It will only attempt to use the unnamed parameter if all three named parameters are empty. If any named parameter is set, it goes back to the code that uses separate parameters defaulted to the current values. (So, {{Days Left|day=28}} → 26 still works as expected in the sandbox version.)
  2. As a consequence of the changed default handling, if no parameters are set at all, the math will now be based on the #time: parser function's currrent time value, rather than a reconstructed DD-MM-YYYY date. As a result, it will return "0" instead of "-0" when called with no parameters. (Told you this one was dumb.)
  3. In the code that works off of separated arguments, I reversed the constructed date to YYYY-MM-DD format. It just felt safer for the parser function.

I've created a set of testcases for both old and new functionality (so, some of them are currently failing, as expected), but they should demonstrate that the updated code still handles previously-supported transclusions properly.

Please let me know (and ping me, please) about any concerns or suggestions, otherwise I'd like to make the new code live pretty soon and update the documentation. FeRDNYC (talk) 06:13, 13 November 2022 (UTC)Reply

These changes are now live. FeRDNYC (talk) 09:47, 12 December 2022 (UTC)Reply