跳转到内容

模板:Countdown:修订间差异

来自osm&bio
Magezeya留言 | 贡献
无编辑摘要
Magezeya留言 | 贡献
无编辑摘要
第2行: 第2行:
{{#if: {{{1|}}}
{{#if: {{{1|}}}
   | {{#if: {{{utc|}}}
   | {{#if: {{{utc|}}}
     | {{#if: {{#pos:{{{1}}}|:}}
     | {{#ifexpr: {{#pos:{{{1}}}|:}} > 0
       | {{#time: U | {{{1}}} {{{utc}}} }}
       | {{#expr: floor(({{#time: U}} - {{#time: U | {{{1}}} {{{utc}}} }}) /
       | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
          {{#switch: {{{time|day}}}
            | day = 86400
            | hour = 3600
            | minute = 60
            | second = 1
          }})
      }}
       | {{#expr: floor(({{#time: U}} - {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}) /
          {{#switch: {{{time|day}}}
            | day = 86400
            | hour = 3600
            | minute = 60
            | second = 1
          }})
      }}
     }}
     }}
     | {{#if: {{#pos:{{{1}}}|:}}
     | {{#ifexpr: {{#pos:{{{1}}}|:}} > 0
       | {{#time: U | {{{1}}} }}
       | {{#expr: floor(({{#time: U}} - {{#time: U | {{{1}}} }}) /
       | {{#time: U | {{{1}}} 00:00:00 }}
          {{#switch: {{{time|day}}}
            | day = 86400
            | hour = 3600
            | minute = 60
            | second = 1
          }})
      }}
       | {{#expr: floor(({{#time: U}} - {{#time: U | {{{1}}} 00:00:00 }}) /
          {{#switch: {{{time|day}}}
            | day = 86400
            | hour = 3600
            | minute = 60
            | second = 1
          }})
      }}
     }}
     }}
  }}
  {{#switch: {{{time|day}}}
    | day = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
        | {{#if: {{#pos:{{{1}}}|:}}
          | {{#time: U | {{{1}}} {{{utc}}} }}
          | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
        }}
        | {{#if: {{#pos:{{{1}}}|:}}
          | {{#time: U | {{{1}}} }}
          | {{#time: U | {{{1}}} 00:00:00 }}
        }}
      }})) / 86400) }}
    | hour = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
        | {{#if: {{#pos:{{{1}}}|:}}
          | {{#time: U | {{{1}}} {{{utc}}} }}
          | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
        }}
        | {{#if: {{#pos:{{{1}}}|:}}
          | {{#time: U | {{{1}}} }}
          | {{#time: U | {{{1}}} 00:00:00 }}
        }}
      }})) / 3600) }}
    | minute = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
        | {{#if: {{#pos:{{{1}}}|:}}
          | {{#time: U | {{{1}}} {{{utc}}} }}
          | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
        }}
        | {{#if: {{#pos:{{{1}}}|:}}
          | {{#time: U | {{{1}}} }}
          | {{#time: U | {{{1}}} 00:00:00 }}
        }}
      }})) / 60) }}
    | second = {{#expr: {{#time: U}} - ({{#if: {{{utc|}}}
        | {{#if: {{#pos:{{{1}}}|:}}
          | {{#time: U | {{{1}}} {{{utc}}} }}
          | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
        }}
        | {{#if: {{#pos:{{{1}}}|:}}
          | {{#time: U | {{{1}}} }}
          | {{#time: U | {{{1}}} 00:00:00 }}
        }}
      }}) }}
   }}
   }}
   | 错误:未提供日期参数
   | 错误:未提供日期参数

2025年8月21日 (四) 14:42的版本


倒计时模板

计算指定日期与当前时间的时间差,只输出数字结果。

使用方法

{{Countdown|目标日期|utc=时区|time=精度}}

参数

1
目标日期 (YYYY-MM-DD或YYYY-MM-DD HH:MM:SS格式)
utc
时区偏移 (可选,例如+8表示UTC+8)
time
精度 (可选,day-天/hour-小时/minute-分钟/second-秒,默认为day)

示例

{{Countdown|2023-12-31}} → 输出天数差
{{Countdown|2023-12-31|utc=+8}} → 使用UTC+8时区
{{Countdown|2023-12-31|time=hour}} → 输出小时差
{{Countdown|2023-12-31 12:30:45|time=minute}} → 包含时间的分钟差