tzf-server

command module
v0.13.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: Unlicense Imports: 9 Imported by: 0

README

Simple server convert longitude&latitude to timezone name

[!NOTE]

It's designed as a debugger tool for package tzf, not production ready.

Quick Start

Install

Install via go install
go install github.com/ringsaturn/tzf-server@latest
Download from release page

Please visit https://github.com/ringsaturn/tzf-server/releases to get latest release.

Install from Docker Hub
docker pull ringsaturn/tzf-server

Usage

Usage of tzf-server:
  -disable-print-route
        Disable Print Route
  -hertz-prometheus-host-port string
        Hertz Prometheus Host&Port (default "0.0.0.0:8090")
  -hertz-prometheus-path string
        Hertz Prometheus Path (default "/hertz")
  -http-addr string
        HTTP Host&Port (default "0.0.0.0:8080")
  -path string
        custom data
  -prometheus-enable-go-coll
        Enable Go Collector (default true)
  -prometheus-host-port string
        Prometheus Host&Port (default "0.0.0.0:2112")
  -prometheus-path string
        Prometheus Path (default "/metrics")
  -redis-addr string
        Redis Server Host&Port (default "localhost:6380")
  -type int
        which finder to use Polygon(0) or Fuzzy(1)

For example, start DefaultFinder server:

tzf-server

Or start FuzzyFinder based server:

tzf-server -type 1

Web Pages

[!NOTE]

Please note that the live demo below is runned on a free plan of Render, so it may take a while to start the server. Please do not use it for production.

All supported timezone names

[Experiment] Clickable debugger

I have little knowledge about frontend development so it's just a experiment, most codes are written by ChatGPT 3.5. You can access the prompts from gist.

HTTP API

[!NOTE]

Please note that the live demo below is runned on a free plan of Render, so it may take a while to start the server. Please do not use it for production.

A swagger UI can be found at http://localhost:8080/swagger/index.html.

Or live demo: https://tzf-server.ringsaturn.me/swagger/index.html

Lookup Location's timezone

curl "http://localhost:8080/api/v1/tz?longitude=116.3883&latitude=39.9289"

or live demo:

curl "https://tzf-server.ringsaturn.me/api/v1/tz?longitude=116.3883&latitude=39.9289"

Output:

{
  "timezone": "Asia/Shanghai",
  "abbreviation": "CST",
  "offset": "28800s"
}

Lookup Location's timezones

curl "http://localhost:8080/api/v1/tzs?longitude=87.6168&latitude=43.8254"

or live demo:

curl "https://tzf-server.ringsaturn.me/api/v1/tzs?longitude=87.6168&latitude=43.8254"

Output:

{
  "timezones": [
    {
      "timezone": "Asia/Shanghai",
      "abbreviation": "CST",
      "offset": "28800s"
    },
    {
      "timezone": "Asia/Urumqi",
      "abbreviation": "+06",
      "offset": "21600s"
    }
  ]
}

All supported timezone names

curl "http://localhost:8080/api/v1/tzs/all"

or live demo:

curl "https://tzf-server.ringsaturn.me/api/v1/tzs/all"

Output:

{
  "timezones": [
    {
      "timezone": "Africa/Abidjan",
      "abbreviation": "GMT",
      "offset": "0s"
    },
    // ...
    {
      "timezone": "Etc/GMT+12",
      "abbreviation": "-12",
      "offset": "-43200s"
    }
  ]
}

Redis Protocol Commands

redis-cli

$ redis-cli -p 6380
127.0.0.1:6380> GET_TZ 116.3883 39.9289
Asia/Shanghai
127.0.0.1:6380> GET_TZS 87.4160 44.0400
1) "Asia/Shanghai"
2) "Asia/Urumqi"

redis-py

>>> from redis import Redis
>>> rc = Redis.from_url("redis://localhost:6380")
>>> rc.ping()
True
>>> rc.execute_command("get_tz", 116.3883, 39.9289).decode()
'Asia/Shanghai'
>>> rc.execute_command("get_tzs", 87.4160, 44.0400)
[b'Asia/Shanghai', b'Asia/Urumqi']

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
app
tzf
v1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL