codeant-ai-for-open-source[bot] commented on code in PR #43960: URL: https://github.com/apache/superset/pull/43960#discussion_r4067756490
########## superset-frontend/packages/superset-ui-core/src/time-format/utils/normalizeTimestamp.ts: ########## @@ -1,25 +1,28 @@ /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an + * or more agreed to in writing, software + * distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -export const TS_REGEX = /(\d{4}-\d{2}-\d{2})[\sT](\d{2}:\d{2}:\d{2}\.?\d*).*/; +/** + * Timezone-aware strings carry an explicit UTC offset (`Z` or `±hh:mm`). + * Rewriting them to a bare `Z` would relabel the wall-clock time as UTC, + * shifting the instant; they are returned untouched. Timezone names + * (`UTC`, `Europe/Helsinki`) are not valid ISO offsets and are still + * stripped the historic way. + */ +const TS_REGEX_TZ_AWARE = + /^(\d{4}-\d{2}-\d{2})[T\s](\d{2}:\d{2}:\d{2}\.?\d*)(?:Z|[+-]\d{2}:?\d{2})$/; +const TS_REGEX = /(\d{4}-\d{2}-\d{2})[\sT](\d{2}:\d{2}:\d{2}\.?\d*).*/; Review Comment: ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `b1c5c81`. `TS_REGEX` is now declared with a named `export`, matching the import used by `denormalizeTimestamp`. <sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub> <!-- codeant-auto-resolve-reply --> ########## superset-frontend/packages/superset-ui-core/src/time-format/utils/normalizeTimestamp.ts: ########## @@ -1,25 +1,28 @@ /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an + * or more agreed to in writing, software + * distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -export const TS_REGEX = /(\d{4}-\d{2}-\d{2})[\sT](\d{2}:\d{2}:\d{2}\.?\d*).*/; +/** + * Timezone-aware strings carry an explicit UTC offset (`Z` or `±hh:mm`). + * Rewriting them to a bare `Z` would relabel the wall-clock time as UTC, + * shifting the instant; they are returned untouched. Timezone names + * (`UTC`, `Europe/Helsinki`) are not valid ISO offsets and are still + * stripped the historic way. + */ +const TS_REGEX_TZ_AWARE = + /^(\d{4}-\d{2}-\d{2})[T\s](\d{2}:\d{2}:\d{2}\.?\d*)(?:Z|[+-]\d{2}:?\d{2})$/; +const TS_REGEX = /(\d{4}-\d{2}-\d{2})[\sT](\d{2}:\d{2}:\d{2}\.?\d*).*/; export default function normalizeTimestamp(value: string): string { + if (TS_REGEX_TZ_AWARE.test(value)) { + return value; Review Comment: ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `b1c5c81`. Timezone-aware timestamps with compact offsets are detected and rewritten from `+0330` to the standard `+03:30` form before being returned. <sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub> <!-- codeant-auto-resolve-reply --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
