Template:Time ago: Difference between revisions

Nothing to hide, but nothing to show you either.
Jump to navigation Jump to search
Content added Content deleted
(support for "magnitude" parameter, per discussion)
m (29 revisions imported from wikipedia:Template:Time_ago)
 
(12 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{#invoke:Time ago|main}}<noinclude>
{{#iferror: {{#time:U| {{{1|}}} }}
|{{error|Error: first parameter cannot be parsed as a date or time.}}
|{{#if: {{{magnitude|}}}
|{{#expr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / {{#switch:{{{magnitude}}}
|minutes = 60
|hours = 3600
|days = 86400
|weeks = 604800
|months = 2678400
|years = 31557600
|#default= 1
}} ) }} {{#switch:{{{magnitude}}}
|minutes
|hours
|days
|weeks
|months
|years = {{{magnitude}}}
|#default= seconds
}}
| <!-- No specific magnitude -->{{#switch:{{#expr:
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 120 ) | 1 | 0 }}+
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 7200 ) | 1 | 0 }}+
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 172800 ) | 1 | 0 }}+
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 5356800 ) | 1 | 0 }}+
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 63115200 ) | 1 | 0 }}
}}
|0 = {{#expr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 1 ) }} seconds
|1 = {{#expr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 60 ) }} minutes
|2 = {{#expr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 3600 ) }} hours
|3 = {{#expr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 86400 ) }} days
|4 = {{#expr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 2678400 ) }} months
|5 = {{#expr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 31557600 ) }} years
}}
}}{{#ifexpr: {{#time:U}} - {{#time:U| {{{1|}}} }} >= 0
|&#32;ago
|' time
}}
}}<noinclude>
{{documentation}}
{{documentation}}
<!-- Categories go in the /doc subpage and interwikis go in Wikidata. -->
</noinclude>
</noinclude>

Latest revision as of 23:23, 7 June 2021

0 seconds ago