Skip to content
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

Rendering of timestamps before 1970-01-01 (negative values in BIGINT) shows "Invalid Timestamp" #839

Open
ckurze opened this issue Jan 22, 2024 · 2 comments
Labels

Comments

@ckurze
Copy link

ckurze commented Jan 22, 2024

Issue:

The AdminUI automatically renders TIMESTAMP fields, which is very convenient.

Anyway, negative millisecond values are valid for dates that are before January 1970.

The following statement demonstrates the issue, the positive timestamp is rendered correctly, the negative one not:

-- Correct:
select ('1970-01-01T00:00:00.001000Z')::TIMESTAMP, date_format(1), (1)::TIMESTAMP limit 100;

-- Result
1 (1970-01-01T00:00:00.001Z) | 1970-01-01T00:00:00.001000Z | 1 (1970-01-01T00:00:00.001Z)

-- Incorrect:
select ('1969-12-31T23:59:59.999000Z')::TIMESTAMP, date_format(-1), (-1)::TIMESTAMP limit 100;

-- Result:
-1 (Invalid Timestamp) | 1969-12-31T23:59:59.999000Z | -1 (Invalid Timestamp)

Workaround:
The issue is not really a problem, just confusing - I thought that my import is wrong, until I figured out this is only a rendering issue.

The date_format() function works properly.

@ckurze ckurze changed the title Rendering of timestamps before 1970-01-01 shows "Invalid Timestamp" Rendering of timestamps before 1970-01-01 (negative values in BIGINT) shows "Invalid Timestamp" Jan 22, 2024
@surister
Copy link

I thought long about this auto-render timestamp, it's convenient until it's not and you actually need to see the raw values, perhaps adding some some info-icon next to the column name with a tooltip explaining that this is a value being rendered by the UI and not the raw value itself, and ideally some quick way to disabled this?

@ckurze
Copy link
Author

ckurze commented Jan 23, 2024

Highlighting that it is not the raw value might help (but for dates the value of bigint is shown).

I think we only need to change line 80 here:

var is_valid = timestamp == 0 || (new Date(timestamp)).getTime() > 0;

Instead of testing if .getTime() > 0, we should check if it is a valid date.

@amotl amotl added the bug label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants