jenkins-bot has submitted this change and it was merged.
Change subject: Hygiene: Update lastEdited documentation
......................................................................
Hygiene: Update lastEdited documentation
Change-Id: I29d4d1b52b2c2d1168166ff8a32d1ef67606d22f
---
M javascripts/modules/lastEdited/time.js
1 file changed, 27 insertions(+), 3 deletions(-)
Approvals:
Jdlrobson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/javascripts/modules/lastEdited/time.js
b/javascripts/modules/lastEdited/time.js
index 8de7002..4ba62c3 100644
--- a/javascripts/modules/lastEdited/time.js
+++ b/javascripts/modules/lastEdited/time.js
@@ -2,6 +2,12 @@
var units = [ 'seconds', 'minutes', 'hours', 'days', 'months', 'years'
],
limits = [ 1, 60, 3600, 86400, 2592000, 31536000 ];
+ /**
+ * Calculate the correct unit of timestamp
+ * @param {Number} timestampDelta
+ * @returns {{value: number, unit: string}}
+ * @ignore
+ */
function timeAgo( timestampDelta ) {
var i = 0;
while ( i < limits.length && timestampDelta > limits[i + 1] ) {
@@ -13,17 +19,35 @@
};
}
+ /**
+ * Calculate the correct unit of timestamp delta
+ * @param {Number} timestamp
+ * @returns {{value: number, unit: string}}
+ * @ignore
+ */
function getTimeAgoDelta( timestamp ) {
- var currentTimestamp = Math.round( new Date().getTime() / 1000
),
- delta = timeAgo( currentTimestamp - timestamp );
- return delta;
+ var currentTimestamp = Math.round( new Date().getTime() / 1000
);
+
+ return timeAgo( currentTimestamp - timestamp );
}
+ /**
+ * Whether timestamp delta is less than a day old
+ * @param {{value: number, unit: string}} delta Object of timestamp and
its label
+ * @returns {boolean}
+ * @ignore
+ */
function isRecent( delta ) {
var u = delta.unit;
return $.inArray( u, [ 'seconds', 'minutes', 'hours' ] ) > -1;
}
+ /**
+ * Is delta less than 10 seconds?
+ * @param {{value: number, unit: string}} delta Object of timestamp and
its label
+ * @returns {boolean}
+ * @ignore
+ */
function isNow( delta ) {
return delta.unit === 'seconds' && delta.value < 10;
}
--
To view, visit https://gerrit.wikimedia.org/r/180663
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I29d4d1b52b2c2d1168166ff8a32d1ef67606d22f
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits