Skip to main content

datasette-render-timestamps

PyPI CircleCI License

Datasette plugin for rendering timestamps.

Installation

Install this plugin in the same environment as Datasette to enable this new functionality:

pip install datasette-render-timestamps

The plugin will then look out for integer numbers that are likely to be timestamps - anything that would be a number of seconds from 5 years ago to 5 years in the future.

These will then be rendered in a more readable format.

Configuration

You can disable automatic column detection in favour of explicitly listing the columns that you would like to render using plugin configuration in a metadata.json file.

Add a "datasette-render-timestamps" configuration block and use a "columns" key to list the columns you would like to treat as timestamp values:

{
    "plugins": {
        "datasette-render-timestamps": {
            "columns": ["created", "updated"]
        }
    }
}

This will cause any created or updated columns in any table to be treated as timestamps and rendered.

Save this to metadata.json and run datasette with the --metadata flag to load this configuration:

datasette serve mydata.db --metadata metadata.json

To disable automatic timestamp detection entirely, you can use "columnns": [].

This configuration block can be used at the top level, or it can be applied just to specific databases or tables. Here's how to apply it to just the entries table in the news.db database:

{
    "databases": {
        "news": {
            "tables": {
                "entries": {
                    "plugins": {
                        "datasette-render-timestamps": {
                            "columns": ["created", "updated"]
                        }
                    }
                }
            }
        }
    }
}

Customizing the date format

The default format is %B %d, %Y - %H:%M:%S UTC which renders for example: October 10, 2019 - 07:18:29 UTC. If you want another format, the date format can be customized using plugin configuration. Any format string supported by strftime may be used. For example:

{
    "plugins": {
        "datasette-render-timestamps": {
            "format": "%Y-%m-%d-%H:%M:%S"
        }
    }
}

Release files for datasette-render-timestamps 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for datasette-render-timestamps 1.0.1
File Interpreter ABI Platform
datasette_render_timestamps-1.0.1-py3-none-any.whl Python 3 none any Details

Release files / datasette_render_timestamps-1.0.1-py3-none-any.whl

Download URL datasette_render_timestamps-1.0.1-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
903e5680296f78fb4f71328c3113461026eb0d3ea947a9a3fff5beefd2eee859
BLAKE2b-256 checksum
How to use checksums
b9122ecccfd9e124b010a680e763d50d8eb1f8c452a7d1aea617e4be8d0e177c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page