Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user friendly format for second resolution #4576

Merged
merged 1 commit into from
Feb 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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