You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/09/22 01:24:45 UTC
(superset) branch master updated: fix(superset-ui-core): add year to smart_date_verbose tooltip tiers (#44212)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new fd5efcbf5ba fix(superset-ui-core): add year to smart_date_verbose tooltip tiers (#44212)
fd5efcbf5ba is described below
commit fd5efcbf5bab4c366247995a7f2277d321d1eda4
Author: Abhinav <al...@gmail.com>
AuthorDate: Tue Sep 22 06:54:39 2026 +0530
fix(superset-ui-core): add year to smart_date_verbose tooltip tiers (#44212)
Co-authored-by: Abhinav Dubey <du...@gmail.com>
---
.../src/time-format/formatters/smartDateVerbose.ts | 10 ++--
.../formatters/smartDateVerbose.test.ts | 57 +++++++++++++++++++---
2 files changed, 56 insertions(+), 11 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-core/src/time-format/formatters/smartDateVerbose.ts b/superset-frontend/packages/superset-ui-core/src/time-format/formatters/smartDateVerbose.ts
index e564a3ff946..b64682e4bac 100644
--- a/superset-frontend/packages/superset-ui-core/src/time-format/formatters/smartDateVerbose.ts
+++ b/superset-frontend/packages/superset-ui-core/src/time-format/formatters/smartDateVerbose.ts
@@ -28,11 +28,11 @@ export function createSmartDateVerboseFormatter(locale?: TimeLocaleDefinition) {
label: 'Verbose Adaptative Formatting',
formats: {
millisecond: '.%L',
- second: '%a %b %d, %I:%M:%S %p',
- minute: '%a %b %d, %I:%M %p',
- hour: '%a %b %d, %I %p',
- day: '%a %b %-e',
- week: '%a %b %-e',
+ second: '%a %b %d %Y, %I:%M:%S %p',
+ minute: '%a %b %d %Y, %I:%M %p',
+ hour: '%a %b %d %Y, %I %p',
+ day: '%a %b %-e %Y',
+ week: '%a %b %-e %Y',
month: '%b %Y',
year: '%Y',
},
diff --git a/superset-frontend/packages/superset-ui-core/test/time-format/formatters/smartDateVerbose.test.ts b/superset-frontend/packages/superset-ui-core/test/time-format/formatters/smartDateVerbose.test.ts
index 4443f5a633e..59f1dc80666 100644
--- a/superset-frontend/packages/superset-ui-core/test/time-format/formatters/smartDateVerbose.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/time-format/formatters/smartDateVerbose.test.ts
@@ -39,9 +39,42 @@ describe('smartDateVerboseFormatter', () => {
expect(formatter(new Date('2020-03-01'))).toBe('Mar 2020');
});
- test('shows weekday when any day of the month', () => {
- expect(formatter(new Date('2020-03-03'))).toBe('Tue Mar 3');
- expect(formatter(new Date('2020-03-15'))).toBe('Sun Mar 15');
+ test('shows weekday with year when any day of the month', () => {
+ expect(formatter(new Date('2020-03-03'))).toBe('Tue Mar 3 2020');
+ expect(formatter(new Date('2020-03-15'))).toBe('Sun Mar 15 2020');
+ });
+
+ // Regression test for #44149: tooltips on charts spanning multiple years
+ // (e.g. a 2014-2026 scatter) must include the year, otherwise points in
+ // different years are indistinguishable without looking at the axis.
+ test('shows the year for daily-granularity dates', () => {
+ expect(formatter(new Date('2014-03-20'))).toBe('Thu Mar 20 2014');
+ });
+
+ test('distinguishes the same day of the year across years', () => {
+ expect(formatter(new Date('2014-03-20'))).not.toBe(
+ formatter(new Date('2026-03-20')),
+ );
+ });
+
+ // Review feedback on #44212: the sub-day tiers had the same ambiguity, so
+ // hourly-or-finer tooltips spanning multiple years also need the year.
+ test('shows the year for hourly-granularity dates', () => {
+ expect(formatter(new Date('2014-03-20T15:00:00Z'))).toBe(
+ 'Thu Mar 20 2014, 03 PM',
+ );
+ });
+
+ test('shows the year for minute-granularity dates', () => {
+ expect(formatter(new Date('2014-03-20T15:45:00Z'))).toBe(
+ 'Thu Mar 20 2014, 03:45 PM',
+ );
+ });
+
+ test('shows the year for second-granularity dates', () => {
+ expect(formatter(new Date('2014-03-20T15:45:12Z'))).toBe(
+ 'Thu Mar 20 2014, 03:45:12 PM',
+ );
});
});
describe('when locale is not default', () => {
@@ -103,9 +136,21 @@ describe('smartDateVerboseFormatter', () => {
expect(formatter(new Date('2020-04-01'))).toBe('Abr 2020');
});
- test('shows weekday when any day of the month', () => {
- expect(formatter(new Date('2020-03-03'))).toBe('Ter Mar 3');
- expect(formatter(new Date('2020-03-15'))).toBe('Dom Mar 15');
+ test('shows weekday with year when any day of the month', () => {
+ expect(formatter(new Date('2020-03-03'))).toBe('Ter Mar 3 2020');
+ expect(formatter(new Date('2020-03-15'))).toBe('Dom Mar 15 2020');
+ });
+
+ test('shows the year for sub-day granularity dates', () => {
+ expect(formatter(new Date('2020-03-03T15:00:00Z'))).toBe(
+ 'Ter Mar 03 2020, 03 PM',
+ );
+ expect(formatter(new Date('2020-03-03T15:45:00Z'))).toBe(
+ 'Ter Mar 03 2020, 03:45 PM',
+ );
+ expect(formatter(new Date('2020-03-03T15:45:12Z'))).toBe(
+ 'Ter Mar 03 2020, 03:45:12 PM',
+ );
});
});
});