Mercurial > hg > orthanc-stone
diff Applications/StoneWebViewer/WebApplication/app.js @ 1698:8805a6a01655
"DateFormat" configuration option
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 27 Nov 2020 10:13:15 +0100 |
parents | c2802561d7f9 |
children | 0598c87e1e88 |
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebApplication/app.js Fri Nov 27 09:47:46 2020 +0100 +++ b/Applications/StoneWebViewer/WebApplication/app.js Fri Nov 27 10:13:15 2020 +0100 @@ -321,8 +321,12 @@ if (this.studies[i].selected) { if (s.length > 0) s += ', '; - s += (this.studies[i].tags[STUDY_DESCRIPTION] + ' [' + - this.studies[i].tags[STUDY_DATE] + ']'); + s += this.studies[i].tags[STUDY_DESCRIPTION]; + + var date = this.studies[i].tags[STUDY_DATE]; + if (date.length > 0) { + s += ' [' + this.FormatDate(date) + ']'; + } } } if (s.length == 0) @@ -709,6 +713,26 @@ this.showWindowing = true; } + }, + + FormatDate(date) { + if (date === undefined || + date.length == 0) { + return ''; + } + else { + var format = this.globalConfiguration['DateFormat']; + if (format === undefined) { + // No configuration for the date format, use the DICOM tag as such + return date; + } + else { + var year = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$1'); + var month = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$2'); + var day = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$3'); + return format.replace(/YYYY/g, year).replace(/MM/g, month).replace(/DD/g, day); + } + } } },