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

[SIP-15] Making client time use UTC as the local time #8450

Merged
merged 2 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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