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

Supply fixed now to datemath caluclations #981

Merged
merged 9 commits into from
Dec 13, 2024
16 changes: 13 additions & 3 deletions packages/scenes/src/utils/evaluateTimeRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ export function evaluateTimeRange(
delay?: string
): TimeRange {
const hasDelay = delay && to === 'now';

const now = Date.now();
return {
from: dateMath.parse(from, false, timeZone, fiscalYearStartMonth)!,
to: dateMath.parse(hasDelay ? 'now-' + delay : to, true, timeZone, fiscalYearStartMonth)!,
from: dateMath.toDateTime(from, {
roundUp: false,
timezone: timeZone,
fiscalYearStartMonth: fiscalYearStartMonth,
now: now,
})!,
to: dateMath.toDateTime(hasDelay ? 'now-' + delay : to, {
roundUp: true,
timezone: timeZone,
fiscalYearStartMonth: fiscalYearStartMonth,
now: now,
})!,
raw: {
from: from,
to: to,
Expand Down
Loading