summaryrefslogtreecommitdiff
path: root/internal/router/api-v1-tz.go
diff options
from:
to:
context:
space:
mode:
authorGravatar Saya Andy <145215889+SayaAndy@users.noreply.github.com> 2025-10-28 23:15:23 +0700
committerGravatar GitHub <noreply@github.com> 2025-10-28 23:15:23 +0700
commitbda4faeeed4d9859cfe8afd7952a751683d74bd8 (patch)
tree464c18fed0c21b63b65425f48a3a790229461058 /internal/router/api-v1-tz.go
parentdd69b45d3a41be2b5c38892c3b107770a0f859f2 (diff)
parent1862f232eb70105340a91e74a5630c233a411bca (diff)
downloadweb-0.11.1.tar.gz
web-0.11.1.zip
v0.11.1 (#18)v0.11.1
- refactor: make structurized implementation of routes + separate identity of router - feat: update go to 1.25 - feat: update all dependencies - debug: display routes when debug logs turned on
Diffstat (limited to 'internal/router/api-v1-tz.go')
-rw-r--r--internal/router/api-v1-tz.go37
1 files changed, 0 insertions, 37 deletions
diff --git a/internal/router/api-v1-tz.go b/internal/router/api-v1-tz.go
deleted file mode 100644
index 4e4e462..0000000
--- a/internal/router/api-v1-tz.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package router
-
-import (
- "log/slog"
- "time"
-
- "github.com/gofiber/fiber/v2"
-)
-
-func Api_V1_TZ() func(c *fiber.Ctx) error {
- return func(c *fiber.Ctx) error {
- timestampString := c.Query("timestamp")
- tz := c.Query("tz")
-
- loc, err := time.LoadLocation(tz)
- if err != nil {
- loc = time.UTC
- slog.Warn("unable to parse a client timezone, defaulting to UTC", slog.String("error", err.Error()), slog.String("tz", tz))
- }
-
- var format string
- var timestamp time.Time
- for _, format = range []string{"2006-01-02 15:04:05 -07:00", time.RFC3339} {
- if timestamp, err = time.Parse(format, timestampString); err == nil {
- break
- }
- }
-
- c.Set(fiber.HeaderContentType, fiber.MIMETextPlainCharsetUTF8)
-
- if err != nil {
- return c.Status(fiber.StatusBadRequest).SendString("invalid timestamp format")
- }
-
- return c.Status(fiber.StatusOK).SendString(timestamp.In(loc).Format(format))
- }
-}