Henning Snater has uploaded a new change for review.
https://gerrit.wikimedia.org/r/63452
Change subject: (bug 48145) Passing options object to Time object constructor
......................................................................
(bug 48145) Passing options object to Time object constructor
Introducing an option parameter for the Time object. The calendar name can now
be
specified via this options object.
Change-Id: I7440a77cb1640961f58e1299e43a03d87ecc13c6
---
M DataValues/resources/time.js/time.Time.js
1 file changed, 18 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues
refs/changes/52/63452/1
diff --git a/DataValues/resources/time.js/time.Time.js
b/DataValues/resources/time.js/time.Time.js
index 1ce651f..5935c58 100644
--- a/DataValues/resources/time.js/time.Time.js
+++ b/DataValues/resources/time.js/time.Time.js
@@ -11,9 +11,19 @@
* Constructor for object representing a point in time with a certain
precision.
*
* @param {string} inputtext Text to be interpreted as time.
- * @param {number} explicitPrecision Precission which will overrule the
precision
+ * @param {Object} options
+ * {number} precision: Precision which will overrule the
automatically detected
+ * precision.
+ * {string} calendarname: Default calendar name overruling the
automatically detected
+ * calendar.
*/
- function Time( inputtext, explicitPrecision ) {
+ function Time( inputtext, options ) {
+ options = $.extend( {
+ precision: null,
+ calendarname: null
+ }, options );
+
+
this.getInputtext = function() {
return inputtext;
};
@@ -34,7 +44,9 @@
minute = (result.minute !== undefined) ? result.minute
: 0,
second = (result.second !== undefined) ? result.second
: 0,
utcoffset = '+00:00',
- calendarname = (result.calendarname !== undefined) ?
result.calendarname : 'Gregorian';
+ calendarname = ( options.calendarname )
+ ? options.calendarname
+ : ( result.calendarname !== undefined ) ?
result.calendarname : 'Gregorian';
this.year = function() {
return year;
@@ -52,7 +64,7 @@
return utcoffset;
};
- var precision = explicitPrecision !== undefined ?
explicitPrecision : result.precision;
+ var precision = ( options.precision ) ? options.precision :
result.precision;
this.precision = function() {
return precision;
};
@@ -167,7 +179,7 @@
* TODO: this function shouldn't really be required since the parser
should simply be able to
* take such a string and create a new Time object from it.
*
- * @param {string} signature
+ * @param {string} iso8601String
* @param {number} [precision] If not given, precision will be as high
as possible.
*/
Time.newFromIso8601 = function( iso8601String, precision ) {
@@ -178,7 +190,7 @@
.replace( /([\-\+])?0*/, '$1' )// get rid of trailing
zeroes, keep "-" and "+"
.replace( '+', '' ); // get reid of "+"
- return new Time( formattedIso8601, precision );
+ return new Time( formattedIso8601, { precision: precision } );
};
return Time; // expose time.Time
--
To view, visit https://gerrit.wikimedia.org/r/63452
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7440a77cb1640961f58e1299e43a03d87ecc13c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits