Merge "Implement getTimestampString on CommentItem"

This commit is contained in:
jenkins-bot 2022-03-26 21:25:13 +00:00 committed by Gerrit Code Review
commit 63c6aceb2c
2 changed files with 16 additions and 4 deletions

View file

@ -31,6 +31,18 @@ function CommentItem( level, range, signatureRanges, timestamp, author ) {
OO.inheritClass( CommentItem, ThreadItem );
/**
* Get the comment timestamp in a standard format
*
* Uses ISO 8601 date. Almost DateTimeInterface::RFC3339_EXTENDED, but ending with 'Z' instead
* of '+00:00', like Date#toISOString in JavaScript.
*
* @return {string} Comment timestamp in standard format
*/
CommentItem.prototype.getTimestampString = function () {
return this.timestamp.toISOString();
};
/**
* @return {HeadingItem} Closest ancestor which is a HeadingItem
*/

View file

@ -929,7 +929,7 @@ Parser.prototype.computeId = function ( threadItem, previousItems ) {
headline = threadItem.range.startContainer;
id = 'h-' + this.truncateForId( headline.getAttribute( 'id' ) || '' );
} else if ( threadItem instanceof CommentItem ) {
id = 'c-' + this.truncateForId( threadItem.author || '' ).replace( / /g, '_' ) + '-' + threadItem.timestamp.toISOString();
id = 'c-' + this.truncateForId( threadItem.author || '' ).replace( / /g, '_' ) + '-' + threadItem.getTimestampString();
} else {
throw new Error( 'Unknown ThreadItem type' );
}
@ -942,7 +942,7 @@ Parser.prototype.computeId = function ( threadItem, previousItems ) {
headline = threadItemParent.range.startContainer;
id += '-' + this.truncateForId( headline.getAttribute( 'id' ) || '' );
} else if ( threadItemParent instanceof CommentItem ) {
id += '-' + this.truncateForId( threadItemParent.author || '' ).replace( / /g, '_' ) + '-' + threadItemParent.timestamp.toISOString();
id += '-' + this.truncateForId( threadItemParent.author || '' ).replace( / /g, '_' ) + '-' + threadItemParent.getTimestampString();
}
if ( threadItem instanceof HeadingItem ) {
@ -952,7 +952,7 @@ Parser.prototype.computeId = function ( threadItem, previousItems ) {
// heading ID.
var oldestComment = this.getThreadStartComment( threadItem );
if ( oldestComment ) {
id += '-' + oldestComment.timestamp.toISOString();
id += '-' + oldestComment.getTimestampString();
}
}
@ -994,7 +994,7 @@ Parser.prototype.computeName = function ( threadItem ) {
if ( mainComment ) {
name += this.truncateForId( mainComment.author || '' ).replace( / /g, '_' ) +
'-' + mainComment.timestamp.toISOString();
'-' + mainComment.getTimestampString();
}
return name;