Tobias Gritschacher has submitted this change and it was merged. Change subject: (bug 48145) Added a "isValid" function for time.Time ......................................................................
(bug 48145) Added a "isValid" function for time.Time The function returns whether the Object is representing any time at all. It will return false if the value passed to the constructor has not been interpreted as time. Change-Id: Ic16ecb54424e2e93ff7c72f30d107abd7b4ac814 --- M DataValues/resources/time.js/time.Time.js 1 file changed, 10 insertions(+), 0 deletions(-) Approvals: Tobias Gritschacher: Looks good to me, approved jenkins-bot: Verified diff --git a/DataValues/resources/time.js/time.Time.js b/DataValues/resources/time.js/time.Time.js index cf393cd..2511ae7 100644 --- a/DataValues/resources/time.js/time.Time.js +++ b/DataValues/resources/time.js/time.Time.js @@ -133,6 +133,16 @@ return time.getTextFromDate( precision, year, month, day ); }; + /** + * Returns whether the Object is representing any time at all. This will be false if the + * value passed to the constructor has not been interpreted as time. + * + * @returns {boolean} + */ + this.isValid = function() { + return this.year() !== null; + }; + this.gregorianText = function() { var result = this.gregorian(); return time.getTextFromDate( precision, result.year, result.month, result.day ); -- To view, visit https://gerrit.wikimedia.org/r/61525 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic16ecb54424e2e93ff7c72f30d107abd7b4ac814 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/DataValues Gerrit-Branch: master Gerrit-Owner: Daniel Werner <daniel.wer...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits