Visitar URL original
Add option to select the timezone in the UI by nitzan-tz · Pull Request #2631 · akvorado/akvorado · GitHub
Skip to content

Add option to select the timezone in the UI - #2631

Open
nitzan-tz wants to merge 6 commits into
akvorado:mainfrom
nitzan-tz:main
Open

nitzan-tz wants to merge 6 commits into
akvorado:mainfrom
nitzan-tz:main

Conversation

@nitzan-tz

Copy link
Copy Markdown
Contributor

Curently the timezone is the browser timezone but in some cases when you work with a team in multiple timezones it is required to have a common timezone.
This option mimics similar option in Grafana

@vincentbernat

Copy link
Copy Markdown
Member

Currently, this is far too much code for such a feature. It spreads too much.

@vincentbernat vincentbernat added the service::console Impact the console service label Sep 13, 2026
@codecov

codecov Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.83%. Comparing base (5c109f3) to head (b4ea983).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2631      +/-   ##
==========================================
- Coverage   90.84%   90.83%   -0.01%     
==========================================
  Files         250      250              
  Lines       14403    14403              
==========================================
- Hits        13084    13083       -1     
- Misses       1319     1320       +1     
Flag Coverage Δ
e2e 53.02% <ø> (+0.02%) ⬆️
unittests 90.34% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…c to useTimezone composable

- Deleted TimezoneProvider.vue and its associated logic.
- Introduced useTimezone composable to manage timezone settings and provide necessary functions.
- Updated various components and views to utilize the new useTimezone composable for timezone management.
- Removed outdated timezone utility functions and tests, consolidating functionality within the new composable.
- Adjusted data handling in graphs to directly use timestamps without shifting for timezone.
- Enhanced tooltip formatting for time display based on selected timezone.
@vincentbernat

vincentbernat commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

The change size is now OK. Thanks!

  • The dates displayed in the start/end fields are still local to the browser time zone. It's confusing. I don't know if there is an easy way around that.
  • The X-axis tooltip stays in local browser time.
  • The tick for the day disappear. Dunno exactly why either, but previously, midnight was converted to the day. If we zoom out for several days, the X ticks become a bit odd.
  • Just "Browser time", otherwise the selection box takes two lines.
  • There is a vertical space issue, but if you rebase on main, it should be OK

@nitzan-tz

Copy link
Copy Markdown
Contributor Author

Let me work on it to add the missing parts

nitzan-tz and others added 2 commits September 19, 2026 17:10
- Shorten timezone selector label to "Browser time" to avoid two-line wrapping
- Support timezone-aware start and end time inputs with automatic conversion on timezone change
- Format X-axis pointer crosshair label according to the selected timezone
- Improve X-axis tick formatting with multi-level awareness and midnight-to-day conversion
- Ensure consistent 24-hour time formatting in the request summary header
- Add comprehensive test coverage for timezone parsing, formatting, and conversion helpers

@vincentbernat vincentbernat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change now looks quite big and "brittle". It's difficult to review and I think it will be difficult to maintain properly.

For Sugar, it seems there is newDateInternal that could help, but I am not 100% sure it would cover all the cases.

For Echarts, there is issue apache/echarts#14453 and proposal apache/echarts#21739. If it helps, we could patch Echarts.

Alternatively, we could patch "Date" instead. This does not look trivial, but the change would be "contained".


// Pre-computed list of timezone options
export const timezones: TimezoneItem[] = [
{ id: 1, code: "browser", name: `Browser Time (${browserTimezone})` },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the field big for most users. Just Browser time.

const trimmed = str.trim();

// If already ends with Z or has timezone offset (+/-HH:MM), native Date handles it
if (/[zZ]|[+-]\d{2}(:?\d{2})?$/.test(trimmed)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also matches "2026-10-07".

humanStart: start.toISOString(),
humanEnd: end.toISOString(),
humanStart: formatTimezoneDateTime(start),
humanEnd: formatTimezoneDateTime(end),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is useful. When you share a link and your time zones don't match, you get the wrong values.

};

export const formatTimezoneAxisPointer = (val: string | number): string => {
return formatTimezoneDateTime(val);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this function is useful if it's just an alias?

return formatTimezoneDateTime(val);
};

export const timezoneAxisFormatter = (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see three concerns:

  • the function is pretty big (and the code looks like a bit redundant)
  • no ticks will match midnight if there is a timezone like +07:30
  • we end up with several ticks for the same day (Paris, we have the day at 00:00 UTC as well as for 22:00 UTC).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

service::console Impact the console service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants