jenkins-bot has submitted this change and it was merged. Change subject: Fix conversion from uuid to timestamp to work in IE ......................................................................
Fix conversion from uuid to timestamp to work in IE IE uses scientific notation for string representation of large numbers. It has to be fully expanded to regular notation for the conversion algorithm to work properly. Bug: T92917 Change-Id: I9d65312ea2c84bf7b577ecf668f1d07d1e9c5744 --- M modules/engine/components/flow-component.js 1 file changed, 25 insertions(+), 1 deletion(-) Approvals: Mattflaschen: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/engine/components/flow-component.js b/modules/engine/components/flow-component.js index ffba356..563cb8e 100644 --- a/modules/engine/components/flow-component.js +++ b/modules/engine/components/flow-component.js @@ -80,11 +80,35 @@ /** * Converts a Flow UUID to a UNIX timestamp. + * + * Example: sfhzxr5a00jkf405 -> 1429101316919 + * * @param {String} uuid * @return {int} UNIX time */ mw.flow.uuidToTime = FlowComponent.prototype.uuidToTime = function ( uuid ) { - var timestamp = parseInt( uuid, 36 ).toString( 2 ); // Parse from base-36, then serialize to base-2 + + var timestamp, + _expandScientificNotation = function ( timestamp ) { + var parts, first, zeroes; + + if ( timestamp.indexOf( 'e' ) !== -1 ) { + parts = timestamp.split( '(e+' ); + first = parts[0].replace( '.', '' ); + zeroes = parseInt( parts[1], 10 ) - (first.length - 1); + first += Array( zeroes + 1 ).join( '0' ); + + return first; + } + + return timestamp; + }; + + timestamp = parseInt( uuid, 36 ).toString( 2 ); // Parse from base-36, then serialize to base-2 + + // IE's toString converts large numbers to scientific notation ( 1.1001110011(e+23) ) + timestamp = _expandScientificNotation( timestamp ); + timestamp = Array( 88 + 1 - timestamp.length ).join( '0' ) + timestamp; // left pad 0 to 88 chars timestamp = parseInt( timestamp.substr( 0, 46 ), 2 ); // first 46 chars base-2 to base-10 -- To view, visit https://gerrit.wikimedia.org/r/204266 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9d65312ea2c84bf7b577ecf668f1d07d1e9c5744 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: Sbisson <sbis...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits