|
|
| 第1行: |
第1行: |
| <includeonly> | | <includeonly> |
| <!-- 正倒计时模板 --> | | <!-- 简化倒计时模板 --> |
| <div class="countdown-container" style="border: 1px solid #ddd; padding: 15px; margin: 10px 0; border-radius: 5px; background: #f9f9f9;">
| | {{#if: {{{1|}}} |
| <h3 style="margin-top: 0; color: #0645ad;">{{#if: {{{title|}}}|{{{title}}}|倒计时}}</h3>
| | | {{#time: U | {{{1}}} }} |
|
| | {{#ifexpr: {{#time: U | {{{1}}} }} > {{#time: U}} |
| {{#if: {{{date|}}} | | | <!-- 未来日期 - 倒计时 --> |
| | {{#time: U | {{{date}}} }}
| | 距离{{{1}}}还有 <strong>{{#expr: floor(({{#time: U | {{{1}}} }} - {{#time: U}}) / 86400) }}</strong> 天 |
| {{#ifexpr: {{#time: U | {{{date}}} }} > {{#time: U}}
| | | <!-- 过去日期 - 正计时 --> |
| | <!-- 未来日期 - 倒计时 -->
| | {{{1}}}已过去 <strong>{{#expr: floor(({{#time: U}} - {{#time: U | {{{1}}} }}) / 86400) }}</strong> 天 |
| <div style="text-align: center;"> | | }} |
| <div style="font-size: 1.5em; color: #d33; margin: 10px 0;">
| | | 错误:未提供日期参数 |
| 距离{{{event|目标日期}}}
| | }} |
| </div>
| |
| <div style="display: flex; justify-content: center; gap: 10px;">
| |
| <div style="background: #fff; padding: 10px; border-radius: 5px; min-width: 60px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
| |
| <div style="font-size: 2em; font-weight: bold;">{{#expr: floor(({{#time: U | {{{date}}} }} - {{#time: U}}) / 86400) }}</div>
| |
| <div style="font-size: 0.9em;">天</div>
| |
| </div>
| |
| </div>
| |
| <div style="margin-top: 10px; color: #666; font-size: 0.9em;">
| |
| 目标日期: {{#time: Y年m月d日 | {{{date}}} }}
| |
| </div>
| |
| </div>
| |
| | <!-- 过去日期 - 正计时 -->
| |
| <div style="text-align: center;"> | |
| <div style="font-size: 1.5em; color: #14866d; margin: 10px 0;">
| |
| {{{event|目标日期}}}已过去:
| |
| </div>
| |
| <div style="display: flex; justify-content: center; gap: 10px;">
| |
| <div style="background: #fff; padding: 10px; border-radius: 5px; min-width: 60px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
| |
| <div style="font-size: 2em; font-weight: bold;">{{#expr: floor(({{#time: U}} - {{#time: U | {{{date}}} }}) / 86400) }}</div>
| |
| <div style="font-size: 0.9em;">天</div>
| |
| </div>
| |
| </div>
| |
| <div style="margin-top: 10px; color: #666; font-size: 0.9em;">
| |
| 起始日期: {{#time: Y年m月d日 | {{{date}}} }}
| |
| </div>
| |
| </div>
| |
| }}
| |
| | <div style="color: #d33; text-align: center;">错误:未提供日期参数</div> | |
| }}
| |
| | |
| {{#if: {{{update|}}}
| |
| | <div style="margin-top: 10px; font-size: 0.8em; color: #666; text-align: center;">
| |
| 最后更新: {{#time:Y-m-d H:i|{{{update}}}}}
| |
| </div>
| |
| }}
| |
| </div>
| |
| </includeonly> | | </includeonly> |
|
| |
|
| 第55行: |
第19行: |
| === 使用方法 === | | === 使用方法 === |
| <pre> | | <pre> |
| {{Countdown | | {{Countdown|目标日期}} |
| |date = 目标日期 (YYYY-MM-DD格式) | |
| |title = 可选标题 (默认为"倒计时")
| |
| |event = 事件名称 (默认为"目标日期")
| |
| |update = 最后更新时间 (可选)
| |
| }} | |
| </pre> | | </pre> |
|
| |
|
| === 示例 === | | === 示例 === |
| <pre> | | <pre> |
| {{Countdown | | {{Countdown|2023-12-31}} // 显示距离2023年12月31日还有/已过多少天 |
| |date = 2023-12-31 | | {{Countdown|2023-06-15}} // 显示距离2023年6月15日还有/已过多少天 |
| |title = 新年倒计时 | |
| |event = 元旦
| |
| }} | |
| </pre> | | </pre> |
|
| |
|
| [[Category:时间模板]] | | [[Category:时间模板]] |
| </noinclude> | | </noinclude> |
倒计时/正计时模板
用于显示距离某个日期的倒计时或已过去的时间。
使用方法
{{Countdown|目标日期}}
示例
{{Countdown|2023-12-31}} // 显示距离2023年12月31日还有/已过多少天
{{Countdown|2023-06-15}} // 显示距离2023年6月15日还有/已过多少天