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)
(recode, and support for min_magnitude parameter)
Line 1: Line 1:
{{#iferror: {{#time:U| {{{1|}}} }}
{{#iferror: {{#time:U| {{{1|}}} }}
|{{error|Error: first parameter cannot be parsed as a date or time.}}
|{{error|Error: first parameter cannot be parsed as a date or time.}}
|{{Time ago/core
|{{#if: {{{magnitude|}}}
|time = {{{1|}}}
|{{#expr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / {{#switch:{{{magnitude}}}
|auto_magnitude_num = {{#if:{{{magnitude|}}}
|minutes = 60
|0<!-- Make sure the specified {{{magnitude}}} is used -->
|hours = 3600
|{{#expr:{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 120 ) | 1 | 0 }}+
|days = 86400
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 7200 ) | 1 | 0 }}+
|weeks = 604800
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 172800 ) | 1 | 0 }}+
|months = 2678400
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 5356800 ) | 2 | 0 }}+
|years = 31557600
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 63115200 ) | 1 | 0 }}
|#default= 1
}}
}} ) }} {{#switch:{{{magnitude}}}
|minutes
|hours
|days
|weeks
|months
|years = {{{magnitude}}}
|#default= seconds
}}
}}
| <!-- No specific magnitude -->{{#switch:{{#expr:
|min_magnitude_num = {{#switch:{{#if:{{{magnitude|}}}
|{{{magnitude}}}
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 120 ) | 1 | 0 }}+
|{{{min_magnitude}}}
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 7200 ) | 1 | 0 }}+
}}
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 172800 ) | 1 | 0 }}+
|years = 6
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 5356800 ) | 1 | 0 }}+
|months = 5
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 63115200 ) | 1 | 0 }}
|weeks = 4
|days = 3
|hours = 2
|minutes = 1
|seconds
|#default= 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>
}}<noinclude>

Revision as of 21:12, 27 January 2010

Template:Time ago/core