SEPURI-SAI-KRISHNA commented on code in PR #45410:
URL: https://github.com/apache/superset/pull/45410#discussion_r4322298384
##########
superset/charts/client_processing.py:
##########
@@ -835,6 +852,26 @@ def union_currency_context(
}
+def is_strftime_expressible(d3_time_format: str) -> bool:
+ """Whether every directive in a d3 time format means the same to
strftime."""
+ directives = re.findall(r"%(.)", d3_time_format)
Review Comment:
Confirmed, and rejected now. `TimeFormatterRegistry.get` takes the marker
off before it builds anything:
```ts
const useLocalTime = targetFormat.startsWith(LOCAL_PREFIX);
const formatString = targetFormat.replace(LOCAL_PREFIX, '');
```
so `local!%Y-%m-%d` reached `strftime` with the marker still on it and gave
`local!2024-04-02`.
```python
if LOCAL_TIME_PREFIX in d3_time_format:
# ``TimeFormatterRegistry.get`` strips the marker before building the
# formatter, so leaving it in would render it as literal text.
return False
```
Rejecting rather than stripping, for the reason behind the marker: it asks
for the viewer's own time zone, and the server cannot reproduce that. Stripping
it would format in UTC and quietly answer a different question, which is worse
than leaving the column raw.
I used `in` rather than `startswith` to match the registry: only a prefix
sets `useLocalTime`, but `replace` takes the first occurrence wherever it sits,
so `%Y local!` loses it in the browser and would keep it here.
`local!%Y-%m-%d` is now one of the cases in
`test_table_skips_a_time_format_strftime_cannot_express`.
--
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]