DataflareApp / Dataflare

Simple, easy-to-use database manager
https://dataflare.app
140 stars 1 forks source link

[Feature Request] Show ISO8601 datetime preview for UNIX times #56

Open jasongitmail opened 7 months ago

jasongitmail commented 7 months ago

Describe the solution you'd like

One feature I dream of in a database viewer is an ability to easily view a human-readable ISO8601 datetime string representation of a UNIX time column in a database.

Problem

Currently I store two columns b/c I'm using sqlite, need a UNIX time in my app and to enable easy sorting within my database queries, but also want an human-readable date to help when manually viewing the database using Dataflare.

But this is redundant data and increases the database size.

Solution

Allow right-click on a number-type column to enable preview of UNIX times as an ISO8601 string like 2024-02-16T23:59:59Z and show this as faint gray text next to the blue UNIX time. The code should handle UNIX times in either seconds or milliseconds. Dataflare should remember the setting for the column, if possible.

The reason to make it a column-level setting is to allow it to be disabled if the number does not represent a UNIX time or enabled if it does.

wyhaya commented 7 months ago

Another way I can think of is to allow write JavaScript script to rewrite cell, but that may be too complicated for many people.

export const rewriteCellValue = (table, column, value) => {

    if(table == 'users' && column == 'create_at') {
        // 2024-02-16T23:59:59Z
        return new Date(value).toISOString()
    }

    if(table == 'users' && column == 'update_at') {
        // 10 days ago
        return timeAgo(value)   
    }

}
jasongitmail commented 7 months ago

Personally, I'd only want to see the actual date as ISO8601, and not a relative date, given this is for viewing my canonical data and isn't an end user's UX