mirror of
https://github.com/Xevion/time-banner.git
synced 2025-12-06 05:16:47 -06:00
2704a214b90d0d97fd400984021b4d8e1418d1e0
time-banner
My first Rust project, intended to offer a simple way to display the current time relative, in an image format.
Planned Features
- Dynamic light/dark mode
- Via Query Parameters for Raster or SVG
- Via CSS for SVG
- Relative or Absolute Format
- Dynamic Formats
- Caching Abilities
- Relative caching for up to 59 seconds, purged on the minute
- Absolute caching for up to 50MB, purged on an LRU basis
- Flexible & Dynamic Browser API
- Allow users to play with format in numerous ways to query API
- Examples
/svg/2023-06-14-3PM-CST2023-06-14-3PM-CST.svg/jpeg/2023.06.14.33(14th of June, 2023, 2:33 PM UTC)/jpeg/2023.06.14.33T-5(14th of June, 2023, 2:33 PM UTC-5)
Routes
/{time}[.{ext}]
/{rel|relative}/{time}[.{ext}]
/{abs|absolute}/{time}[.{ext}]
- If relative or absolute is not specified, it will be the opposite of the time string's format.
Query Parameters
format- Specify the format of the time stringtz- Specify the timezone of the time string. May be ignored if the time string contains a timezone/offset.
Structure
- Routing
- Handle different input formats at the route layer
- Parsing
- Module for parsing input
- Cache Layer
- Given all route options, provide a globally available cache for the next layer
- SVG Template Rendering
- Template rendering based on parsed input
- (Optional) Rasterization
- If rasterization is requested, render SVG to PNG
- (Catch-all) Error Handling
- All errors/panics will be caught in separate middleware
Input Parsing
- Date formatting will be guesswork, but can be specified with
?format=parameter.- To avoid abuse, it will be limited to a subset of the
chronoformatting options.
- To avoid abuse, it will be limited to a subset of the
- The assumed extension when not specified is
.svgfor performance sake..pngis also available..jpegand.webpare planned.
- Time is not required, but will default each value to 0 (except HOUR, which is the minimum specified value).
- Millisecond precision is allowed, but will be ignored in most outputs. Periods or commas are allowed as separators.
- Timezones can be qualified in a number of ways, but will default to UTC if not specified.
- Fully qualified TZ identifiers like "America/Chicago" are specified using the
tzquery parameter. - Abbreviated TZ identifiers like "CST" are specified inside the time string, after the time, separated by a dash.
- Abbreviated terms are incredibly ambiguous, and should be avoided if possible. For ease of use, they are available, but several of them are ambiguous, and the preferred TZ has been specified in code.
- Full table available in
abbr_tz. Comments designated with#. Preferred interpretation designated arbitrarily by me. Table sourced from Wikipedia
- Fully qualified TZ identifiers like "America/Chicago" are specified using the
Description
Languages
Rust
90.3%
Just
5.7%
Dockerfile
4%