Skip to content

Commit

Permalink
Merge pull request #4576 from camptocamp/wmstime
Browse files Browse the repository at this point in the history
Add user friendly format for second resolution
  • Loading branch information
sbrunner committed Feb 1, 2019
2 parents debe6a2 + 8a35aab commit 7587a5d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/misc/WMSTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ exports.prototype.formatTimeValue = function(time, resolution, opt_useISOFormat,
let yearResolution = 'yyyy';
let monthResolution = 'yyyy-MM';
let dayResolution = 'yyyy-MM-dd';
let secondResolution = undefined;

// Localized format.
if (!opt_useISOFormat) {
const gettextCatalog = this.gettextCatalog_;
yearResolution = gettextCatalog.getString('yyyy');
monthResolution = gettextCatalog.getString('M/yyyy');
dayResolution = gettextCatalog.getString('M/d/yyyy');
secondResolution = gettextCatalog.getString('M/d/yyyy HH:MM:ss');
}

switch (resolution) {
Expand All @@ -69,6 +71,12 @@ exports.prototype.formatTimeValue = function(time, resolution, opt_useISOFormat,
return this.$filter_('date')(date, monthResolution, utc);
case 'day':
return this.$filter_('date')(date, dayResolution, utc);
case 'second':
if (secondResolution) {
return this.$filter_('date')(date, secondResolution, utc);
} else {
return date.toISOString().replace(/\.\d{3}/, '');
}
default:
//case "second":
return date.toISOString().replace(/\.\d{3}/, '');
Expand Down

0 comments on commit 7587a5d

Please sign in to comment.