Template talk:How long ago
This template was based on "Template:User Wikipedian For", which was itself translated from the Hebrew Wikipedia.
Example usage
[edit]Code | Result |
---|---|
{{How Long Ago|year=2004|month=3|day=10}} | 20 years, 8 months and 11 days |
This template was created {{How Long Ago|year=2007|month=11|day=20}} ago | This template was created 17 years and 1 day ago |
Bug in the calculations?
[edit]Looking at the doc page today (25 Mar 2011), there's a glitch. A call of {{How long ago|2004|3|10}} returns "6 years and 15 days", but a call of {{How long ago|year=2004|month=3|day=10}} correctly returns "7 years and 15 days".
I don't see the error, but I know where it is in the code. If those more familiar with the template could take a look, I'd appreciate it. —C.Fred (talk) 16:50, 25 March 2011 (UTC)
- Looks like I'm not the first to spot this problem. It's been fixed. I suspect the reason it wasn't fixed before now is the utter mess the template code is in. Just a general FYI, there's a much more elegantly written version of this template at Template:For_year_month_day, plus its code is actually readable, and it also recognizes the 100- and 400-year leap-year rules, which this template ignores. --Iritscen (talk) 18:13, 12 June 2013 (UTC)
Formatting bug
[edit]An extra space seems to appear between the word ‘and’ and the second number in this template when the amount of time elapsed is exactly a certain number of months after the initial event. For example, using this template today (November 5) for a hypothetical event that occurred on August 5, 2010 yields:
- 14 years, 3 months and 16 days (5 years and 3 months; feel free to update it so that the amount of time elapsed is exactly a certain number of months after the day you're editing it on)
I've looked at the code and I don't really understand it, so I'd appreciate it if someone else could fix it. Esszet (talk) 19:31, 5 November 2015 (UTC)
- I believe I corrected the mistake:
- 14 years, 3 months and 2 days
- I've looked at some sample output of the template and I don't see any cases where there is a missing space before "months", but if anyone sees one, feel free to revert. I had never looked closely at the /exp page before, where the problem was. The markup there is pretty bad too (the indentation and linebreaks do not convey the logic structure at all). --Iritscen (talk) 00:07, 19 November 2015 (UTC)