Skip to content

Commit

Permalink
[SIP-15] Making client time use UTC as the local time (#8450)
Browse files Browse the repository at this point in the history
* [fix] Making client time UTC

* Update UPDATING.md
  • Loading branch information
john-bodley authored Oct 28, 2019
1 parent a757b43 commit f7f0be5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ assists people when migrating to a new version.

## Next Version

* [8450](https://github.com/apache/incubator-superset/pull/8450): The time ranger picker
now uses UTC for the tooltips and default placeholder timestamps (sans timezone).

* [8370](https://github.com/apache/incubator-superset/pull/8370): Deprecates
the `HTTP_HEADERS` variable in favor of `DEFAULT_HTTP_HEADERS` and
`OVERRIDE_HTTP_HEADERS`. To retain the same behavior you should use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,15 @@ const COMMON_TIME_FRAMES = [
const TIME_GRAIN_OPTIONS = ['seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years'];

const MOMENT_FORMAT = 'YYYY-MM-DD[T]HH:mm:ss';
const DEFAULT_SINCE = moment().startOf('day').subtract(7, 'days').format(MOMENT_FORMAT);
const DEFAULT_UNTIL = moment().startOf('day').format(MOMENT_FORMAT);
const DEFAULT_SINCE = moment()
.utc()
.startOf('day')
.subtract(7, 'days')
.format(MOMENT_FORMAT);
const DEFAULT_UNTIL = moment()
.utc()
.startOf('day')
.format(MOMENT_FORMAT);
const SEPARATOR = ' : ';
const FREEFORM_TOOLTIP = t(
'Superset supports smart date parsing. Strings like `last sunday` or ' +
Expand Down Expand Up @@ -116,8 +123,12 @@ function getStateFromCommonTimeFrame(value) {
tab: TABS.DEFAULTS,
type: TYPES.DEFAULTS,
common: value,
since: moment().startOf('day').subtract(1, units).format(MOMENT_FORMAT),
until: moment().startOf('day').format(MOMENT_FORMAT),
since: moment()
.utc()
.startOf('day')
.subtract(1, units)
.format(MOMENT_FORMAT),
until: moment().utc().startOf('day').format(MOMENT_FORMAT),
};
}

Expand All @@ -126,13 +137,15 @@ function getStateFromCustomRange(value) {
let since;
let until;
if (rel === RELATIVE_TIME_OPTIONS.LAST) {
until = moment().startOf('day').format(MOMENT_FORMAT);
until = moment().utc().startOf('day').format(MOMENT_FORMAT);
since = moment()
.utc()
.startOf('day')
.subtract(num, grain)
.format(MOMENT_FORMAT);
} else {
until = moment()
.utc()
.startOf('day')
.add(num, grain)
.format(MOMENT_FORMAT);
Expand Down
8 changes: 8 additions & 0 deletions superset/assets/src/explore/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,14 @@ export const controls = {
freeForm: true,
label: t('Time range'),
default: t('Last week'),
description: t(
'The time range for the visualization. All relative times, e.g. "Last month", ' +
'"Last 7 days", "now", etc. are evaluated on the server using the server\'s ' +
'local time (sans timezone). All tooltips and placeholder times are expressed ' +
'in UTC (sans timezone). The timestamps are then evaluated by the database ' +
'using the engine\'s local timezone. Note one can explicitly set the timezone ' +
'per the ISO 8601 format if specifying either the start and/or end time.',
),
},

max_bubble_size: {
Expand Down

0 comments on commit f7f0be5

Please sign in to comment.