打开/关闭搜索
搜索
打开/关闭菜单
549
7
12
2051
OGAS数据中枢
导航
首页
最近更改
随机页面
特殊页面
上传文件
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
查看“︁Widget:TimeSinceLastEdit”︁的源代码
来自OGAS数据中枢
更多语言
查看
阅读
查看源代码
查看历史
associated-pages
Widget
讨论
更多操作
←
Widget:TimeSinceLastEdit
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
管理员
您没有权限编辑
Widget
命名空间内的页面。
您可以查看和复制此页面的源代码。
<noinclude>本 Widget 用于支持 {{tl|TimeSinceLastEdit}} 的功能。非一般情况下请勿使用。</noinclude><includeonly><!--{if !isset($wgTimeSinceLastEdit) || !$wgTimeSinceLastEdit}--><!--{assign var="wgTimeSinceLastEdit" value=true scope="global"}--><script> window.RLQ = window.RLQ || []; window.RLQ.push([["jquery","moment"], () => { // real humanize function humanize(then) { const now = moment(); const isBefore = then.isBefore(now); const monthsHave31Days = [0, 2, 4, 6, 7, 9, 11]; // 月份从0开始 let year = isBefore ? now.year() - then.year() : then.year() - now.year(), month = isBefore ? now.month() - then.month() : then.month() - now.month(), day = isBefore ? now.date() - then.date() : then.date() - now.date(), hour = isBefore ? now.hour() - then.hour() : then.hour() - now.hour(), minute = isBefore ? now.minute() - then.minute() : then.minute() - now.minute(), second = isBefore ? now.second() - then.second() : then.second() - now.second(); if (second < 0) { minute--; second += 60; } if (minute < 0) { hour--; minute += 60; } if (hour < 0) { day--; hour += 24; } if (day < 0) { month--; if (monthsHave31Days.includes((isBefore ? then : now).month())) { day += 31; } else if ((isBefore ? then : now).month() === 1) { if ((isBefore ? then : now).year() % 4 === 0) { day += 29; } else { day += 28; } } else { day += 30; } } if (month < 0) { year--; month += 12; } let result = ""; if (year > 0) { result += `${year }年`; } if (month > 0) { result += `${month }个月`; } else if (result !== "") { result += "0个月"; } if (day > 0) { result += `${day }天`; } else if (result !== "") { result += "0天"; } if (hour > 0) { result += `${hour }小时`; } else if (result !== "") { result += "0小时"; } if (minute > 0) { result += `${minute }分`; } else if (result !== "") { result += "0分"; } if (second > 0) { result += `${second }秒`; } else if (result !== "") { result += "0秒"; } return result + (isBefore ? "前" : "后"); } /** * Refresh */ function tsRefreshDuration() { $(".lastEditTime").each(function() { // Sanity check if (!this.dataset || !this.dataset.lastEditTime) {return;} // FIX BY CASE: In Moegirlpedia's deployment, the Epoch timestamp is incorrect (with 8 hours' difference) // We will fix this by subtract 8 hours (28800 seconds) const lastEditTime = moment.unix(this.dataset.lastEditTime - 28800); if (!lastEditTime || !lastEditTime.isValid()) {return;} // Diff and sanity check const editTimeDiff = moment.duration(moment().diff(lastEditTime)); if (!editTimeDiff || !editTimeDiff.isValid()) { // FIX BY CASE (@Yurin Jasmine): Remind user about local time issue $(this).text("未知时长(请校准您的设备时间再试)"); return; } // Set time $(this).text(humanize(lastEditTime) + (editTimeDiff.asMilliseconds() < 0 ? "(请校准您的设备时间再试)" : "")); }); } window.setInterval(() => { tsRefreshDuration(); }, 1000); // First call tsRefreshDuration(); }]); </script><!--{/if}--></includeonly>
该页面嵌入的页面:
Template:Tl
(
查看源代码
)
Template:Transclude
(
查看源代码
)
返回
Widget:TimeSinceLastEdit
。
查看“︁Widget:TimeSinceLastEdit”︁的源代码
来自OGAS数据中枢