feat(grid): add 12-hour datetime format and timezone aliases

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-30 09:58:34 +08:00
1 parent 694c344278
commit 349342efb7
2 files changed
+15 -2

No files matched your search

@@ -174,6 +174,8 @@ import {
applyColumnFormatter, applyColumnFormatter,
buildColumnFormatterKey, buildColumnFormatterKey,
defaultIoTDBTimestampFormatter, defaultIoTDBTimestampFormatter,
DataGridDateTimePatterns,
displayTimeZoneOption,
formatIoTDBTimestampEditorValue, formatIoTDBTimestampEditorValue,
getSupportedTimeZoneOptions, getSupportedTimeZoneOptions,
iotdbTimestampFractionDigits, iotdbTimestampFractionDigits,
@@ -184,7 +186,6 @@ import {
type ColumnFormatterConfig, type ColumnFormatterConfig,
type DateTimeFormatterUnit, type DateTimeFormatterUnit,
type ForeignKeyDisplayFilterConfig, type ForeignKeyDisplayFilterConfig,
DateTimePatterns,
} from "@/lib/dataGrid/columnFormatter"; } from "@/lib/dataGrid/columnFormatter";
import { temporalCellEditorConfig, type TemporalCellEditorConfig } from "@/lib/dataGrid/dataGridTemporalEditor"; import { temporalCellEditorConfig, type TemporalCellEditorConfig } from "@/lib/dataGrid/dataGridTemporalEditor";
import { BOOLEAN_CELL_EDITOR_VALUES, booleanCellEditorValue, isBooleanCellValue, isBooleanColumnType, isPointInBooleanCheckbox, nextBooleanCellValue, normalizeBooleanCellValue, parseBooleanCellEditorValue } from "@/lib/dataGrid/dataGridBooleanColumn"; import { BOOLEAN_CELL_EDITOR_VALUES, booleanCellEditorValue, isBooleanCellValue, isBooleanColumnType, isPointInBooleanCheckbox, nextBooleanCellValue, normalizeBooleanCellValue, parseBooleanCellEditorValue } from "@/lib/dataGrid/dataGridBooleanColumn";
@@ -12983,7 +12984,7 @@ function openGridSnapshot() {
</div> </div>
<SearchableSelect <SearchableSelect
:model-value="formatterDatetimePattern" :model-value="formatterDatetimePattern"
:options="DateTimePatterns" :options="DataGridDateTimePatterns"
:placeholder="t('grid.formatterDatetimePatternPlaceholder')" :placeholder="t('grid.formatterDatetimePatternPlaceholder')"
:search-placeholder="t('grid.formatterDatetimePatternPlaceholder')" :search-placeholder="t('grid.formatterDatetimePatternPlaceholder')"
:empty-text="t('grid.formatterDatetimePatternEmpty')" :empty-text="t('grid.formatterDatetimePatternEmpty')"
@@ -13002,6 +13003,7 @@ function openGridSnapshot() {
<SearchableSelect <SearchableSelect
:model-value="formatterDateTimezone" :model-value="formatterDateTimezone"
:options="timezoneOptions" :options="timezoneOptions"
:display-name="displayTimeZoneOption"
:placeholder="t('grid.formatterDatetimeTimezonePlaceholder')" :placeholder="t('grid.formatterDatetimeTimezonePlaceholder')"
:search-placeholder="t('grid.formatterDatetimeTimezonePlaceholder')" :search-placeholder="t('grid.formatterDatetimeTimezonePlaceholder')"
:empty-text="t('grid.formatterDatetimeTimezonePlaceholder')" :empty-text="t('grid.formatterDatetimeTimezonePlaceholder')"
@@ -28,6 +28,9 @@ export const DateTimePatterns = [
"YYYY/MM/DDTHH:mm:ssZ", "YYYY/MM/DDTHH:mm:ssZ",
"YYYY/MM/DDTHH:mm:ss.SSSZ", "YYYY/MM/DDTHH:mm:ss.SSSZ",
]; ];
// Keep global date-time formats compatible with the backend; the data grid can
// additionally render Day.js 12-hour display patterns locally.
export const DataGridDateTimePatterns = [...DateTimePatterns, "YYYY-MM-DD hh:mm:ss A"];
const SUPPORTED_DATE_TIME_PATTERN_TOKENS = ["YYYY", "SSS", "ZZ", "MM", "DD", "HH", "mm", "ss", "M", "D", "H", "m", "s", "Z"]; const SUPPORTED_DATE_TIME_PATTERN_TOKENS = ["YYYY", "SSS", "ZZ", "MM", "DD", "HH", "mm", "ss", "M", "D", "H", "m", "s", "Z"];
const STRICT_LOCAL_DATETIME_INPUT_PATTERNS = [ const STRICT_LOCAL_DATETIME_INPUT_PATTERNS = [
"YYYY-MM-DD", "YYYY-MM-DD",
@@ -72,6 +75,14 @@ interface IntlTimeZoneSupport {
supportedValuesOf?: (key: "timeZone") => string[]; supportedValuesOf?: (key: "timeZone") => string[];
} }
const TIME_ZONE_DISPLAY_ALIASES: Record<string, string> = {
"Asia/Calcutta": "Asia/Kolkata",
};
export function displayTimeZoneOption(timeZone: string): string {
return TIME_ZONE_DISPLAY_ALIASES[timeZone] ?? timeZone;
}
export function getSupportedTimeZoneOptions(intl: IntlTimeZoneSupport, fallbackTimeZone = "UTC"): string[] { export function getSupportedTimeZoneOptions(intl: IntlTimeZoneSupport, fallbackTimeZone = "UTC"): string[] {
try { try {
const timeZones = intl.supportedValuesOf?.("timeZone"); const timeZones = intl.supportedValuesOf?.("timeZone");