-
Notifications
You must be signed in to change notification settings - Fork 504
7855 cb add setting use the users os formatting for numbersdates #4020
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
base: devel
Are you sure you want to change the base?
7855 cb add setting use the users os formatting for numbersdates #4020
Conversation
SychevAndrey
commented
Dec 25, 2025
…r numbers and dates
…ridSettingsService
...ges/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/DateTimeFormatter.tsx
Outdated
Show resolved
Hide resolved
...kages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/NumberFormatter.tsx
Show resolved
Hide resolved
webapp/packages/plugin-data-spreadsheet-new/src/DataGridSettingsService.ts
Outdated
Show resolved
Hide resolved
| let value = displayValue; | ||
|
|
||
| if (tableDataContext.useUserFormatting) { | ||
| const isDateOnly = /^\d{4}-\d{2}-\d{2}$/.test(displayValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isDateOnly = /^\d{4}-\d{2}-\d{2}$/.test(displayValue);
Is it really required? This will hit performance in the grid noticeably, at least create a regex outside of the render function.
new Date() should be able to parse a date correctly without time. Maybe you can simplify the check by checking the resulting Date object (probably it will have some constant time)
(or just use unified formatter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it's probably enough to check this format only once for one of the cells because they all will have the same format, or maybe you can check it by column type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can put it on the data context level and set something like "extended datakind" for every column with TIME/DATE/DATETIME values. In the cell we will just get the datakind of the column and use the according formatter. Do you want me refactor like that?
Unfortunately, we can't rely on new Date to check the shape, so testing by regex or splitting is required. However, if we do it only on the TableDataContext level it should be not a problem.
webapp/packages/plugin-data-spreadsheet-new/src/DataGridSettingsService.ts
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-spreadsheet-new/src/DataGridSettingsService.ts
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-spreadsheet-new/src/DataGridSettingsService.ts
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/useTableData.tsx
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/helpers/detectDateTimeKind.ts
Outdated
Show resolved
Hide resolved
| if (this.extendedDateKinds.has(columnKey.index)) { | ||
| return this.extendedDateKinds.get(columnKey.index) as DateTimeKind; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably you want to use ResultSetCacheAction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like an over-engineering to me since we don't need cell or row-level caching here, only the cache by columns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to add getColumn like we have getRow in it, it's better because it will clear cache when needed and place it in one place
webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/useTableData.tsx
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatterFactory.tsx
Outdated
Show resolved
Hide resolved
...lugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/NumberFormatter.module.css
Outdated
Show resolved
Hide resolved
…atting-for-numbersdates
…umbersdates' of github.com:dbeaver/cloudbeaver into 7855-cb-add-setting---use-the-users-os-formatting-for-numbersdates
…atting-for-numbersdates
| switch (extendedDateKind) { | ||
| case DateTimeKind.DateTime: | ||
| case DateTimeKind.TimeOnly: | ||
| dateFormatter = formattingContext.formatters.dateTime; | ||
| break; | ||
| case DateTimeKind.DateOnly: | ||
| dateFormatter = formattingContext.formatters.dateOnly; | ||
| break; | ||
| } | ||
| const date = new Date(displayValue); | ||
| value = dateFormatter!.format(date); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add default formatter here? which is gonna just display something as it is without formatting
cause now this line can break the code:
value = dateFormatter!.format(date);
better to have default switch case to prevent that
webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatterFactory.tsx
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/FormattingContext.ts
Outdated
Show resolved
Hide resolved
| if (this.extendedDateKinds.has(columnKey.index)) { | ||
| return this.extendedDateKinds.get(columnKey.index) as DateTimeKind; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to add getColumn like we have getRow in it, it's better because it will clear cache when needed and place it in one place
webapp/packages/plugin-data-spreadsheet-new/src/DataGridSettingsService.ts
Outdated
Show resolved
Hide resolved
…atting-for-numbersdates
…atting-for-numbersdates