@@ -13,7 +13,7 @@ var PARENT = dv.DataValue;
13
13
*
14
14
* @constructor
15
15
*
16
- * @param {string } iso8601
16
+ * @param {string } timestamp
17
17
* @param {Object } [options]
18
18
* @param {string } [options.calendarModel=dataValues.TimeValue.CALENDARS.GREGORIAN]
19
19
* Wikidata URL of the calendar model.
@@ -22,21 +22,21 @@ var PARENT = dv.DataValue;
22
22
* @param {number } [options.after=0]
23
23
* @param {number } [options.timezone=0]
24
24
*
25
- * @throws {Error } if `iso8601 ` is not a valid ISO 8601 string.
25
+ * @throws {Error } if `timestamp ` is not a valid YMD-ordered timestamp string resembling ISO 8601 .
26
26
*/
27
- var SELF = dv . TimeValue = util . inherit ( 'DvTimeValue' , PARENT , function ( iso8601 , options ) {
27
+ var SELF = dv . TimeValue = util . inherit ( 'DvTimeValue' , PARENT , function ( timestamp , options ) {
28
28
this . _time = { } ;
29
29
30
30
try {
31
- var matches = / ^ ( [ + - ] ? \d + ) - ( \d + ) - ( \d + ) T ( \d { 2 } ) : ( \d { 2 } ) : ( \d { 2 } ) Z $ / . exec ( iso8601 ) ;
31
+ var matches = / ^ ( [ + - ] ? \d + ) - ( \d + ) - ( \d + ) T ( \d { 2 } ) : ( \d { 2 } ) : ( \d { 2 } ) Z $ / . exec ( timestamp ) ;
32
32
this . _time . year = parseInt ( matches [ 1 ] , 10 ) ;
33
33
this . _time . month = parseInt ( matches [ 2 ] , 10 ) ;
34
34
this . _time . day = parseInt ( matches [ 3 ] , 10 ) ;
35
35
this . _time . hour = parseInt ( matches [ 4 ] , 10 ) ;
36
36
this . _time . minute = parseInt ( matches [ 5 ] , 10 ) ;
37
37
this . _time . second = parseInt ( matches [ 6 ] , 10 ) ;
38
38
} catch ( e ) {
39
- throw new Error ( 'Unable to process supposed ISO8601 string' ) ;
39
+ throw new Error ( 'Unable to process supposed timestamp string' ) ;
40
40
}
41
41
42
42
this . _options = {
@@ -105,7 +105,7 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( iso8601
105
105
* @return {string }
106
106
*/
107
107
getSortKey : function ( ) {
108
- return this . _getISO8601 ( ) ;
108
+ return this . _getTimestamp ( ) ;
109
109
} ,
110
110
111
111
/**
@@ -193,12 +193,12 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( iso8601
193
193
} ,
194
194
195
195
/**
196
- * Returns date/time as ISO8601 string.
196
+ * Returns a YMD-ordered timestamp string resembling ISO 8601 .
197
197
* @private
198
198
*
199
199
* @return {string }
200
200
*/
201
- _getISO8601 : function ( ) {
201
+ _getTimestamp : function ( ) {
202
202
return ( ( this . _time . year < 0 ) ? '-' : '+' )
203
203
+ pad ( this . _time . year , 11 ) + '-'
204
204
+ pad ( this . _time . month , 2 ) + '-'
@@ -219,7 +219,7 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( iso8601
219
219
before : this . _options . before ,
220
220
calendarmodel : this . _options . calendarModel ,
221
221
precision : this . _options . precision ,
222
- time : this . _getISO8601 ( ) ,
222
+ time : this . _getTimestamp ( ) ,
223
223
timezone : this . _options . timezone
224
224
} ;
225
225
}
0 commit comments