Skip to content

Commit e8093d0

Browse files
committed
Merge pull request #72 from wmde/donCallMeIso
Avoid calling our timestamp strings ISO
2 parents 3b66b2e + f50dc4c commit e8093d0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ On [Packagist](https://packagist.org/packages/data-values/javascript):
8181
#### Bugfixes
8282

8383
* Fixed definitions of ResourceLoader test modules.
84-
* Accept ISO8601-formatted timestamps with zeroes as months and days
84+
* Accept timestamp strings with zeroes as months and days
8585
* Always return a string in time.writeYear and time.writeDay
8686

8787
### 0.3.1 (2014-02-03)

src/values/TimeValue.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var PARENT = dv.DataValue;
1313
*
1414
* @constructor
1515
*
16-
* @param {string} iso8601
16+
* @param {string} timestamp
1717
* @param {Object} [options]
1818
* @param {string} [options.calendarModel=dataValues.TimeValue.CALENDARS.GREGORIAN]
1919
* Wikidata URL of the calendar model.
@@ -22,21 +22,21 @@ var PARENT = dv.DataValue;
2222
* @param {number} [options.after=0]
2323
* @param {number} [options.timezone=0]
2424
*
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.
2626
*/
27-
var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( iso8601, options ) {
27+
var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( timestamp, options ) {
2828
this._time = {};
2929

3030
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 );
3232
this._time.year = parseInt( matches[1], 10 );
3333
this._time.month = parseInt( matches[2], 10 );
3434
this._time.day = parseInt( matches[3], 10 );
3535
this._time.hour = parseInt( matches[4], 10 );
3636
this._time.minute = parseInt( matches[5], 10 );
3737
this._time.second = parseInt( matches[6], 10 );
3838
} catch( e ) {
39-
throw new Error( 'Unable to process supposed ISO8601 string' );
39+
throw new Error( 'Unable to process supposed timestamp string' );
4040
}
4141

4242
this._options = {
@@ -105,7 +105,7 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( iso8601
105105
* @return {string}
106106
*/
107107
getSortKey: function() {
108-
return this._getISO8601();
108+
return this._getTimestamp();
109109
},
110110

111111
/**
@@ -193,12 +193,12 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( iso8601
193193
},
194194

195195
/**
196-
* Returns date/time as ISO8601 string.
196+
* Returns a YMD-ordered timestamp string resembling ISO 8601.
197197
* @private
198198
*
199199
* @return {string}
200200
*/
201-
_getISO8601: function() {
201+
_getTimestamp: function() {
202202
return ( ( this._time.year < 0 ) ? '-' : '+' )
203203
+ pad( this._time.year, 11 ) + '-'
204204
+ pad( this._time.month, 2 ) + '-'
@@ -219,7 +219,7 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( iso8601
219219
before: this._options.before,
220220
calendarmodel: this._options.calendarModel,
221221
precision: this._options.precision,
222-
time: this._getISO8601(),
222+
time: this._getTimestamp(),
223223
timezone: this._options.timezone
224224
};
225225
}

0 commit comments

Comments
 (0)