diff mbox series

[bug#48364,5/5] gnu: Add tz.

Message ID 20210511185554.67355-5-stefan@xsteve.at
State Accepted
Headers show
Series [bug#48362,1/5] gnu: go-github-com-muesli-reflow-wordwrap: Update to 0.2.0. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Stefan Reichör May 11, 2021, 6:55 p.m. UTC
* gnu/packages/time.scm (tz): New variable.
---
 gnu/packages/time.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Comments

Leo Famulari May 11, 2021, 7:13 p.m. UTC | #1
On Tue, May 11, 2021 at 08:55:54PM +0200, Stefan Reichör wrote:
> * gnu/packages/time.scm (tz): New variable.

> +    (synopsis "Display time across a few selected time zones.")
> +    (description
> +     "tz is a cli tool that displays a given time in several time zones.  Use
> +the environment variable TZ_LIST to specify a list of time zones.")

I'm curious, how does it find the time zone database?

It should look them up at runtime via something like a TZDIR environment
variable. It should not include a copy of the database, or else it will
become "stale" before too long.
Stefan Reichör May 13, 2021, 6:59 p.m. UTC | #2
Another attempt to answer the question from Leo Famulari

I didn't get the question from the bugtracker by email:

,----
| I'm curious, how does it find the time zone database?
| 
| It should look them up at runtime via something like a TZDIR environment
| variable. It should not include a copy of the database, or else it will
| become "stale" before too long.
`----

Yesterday I tried to answer it directly in the web interface. My answer
didn't show up :-(

Now I try to answer per email


The timezone is determined by the go runtime function LoadLocation:

https://github.com/oz/tz/blob/main/zone.go#L77


LoadLocation does the lookup in the installed timezone database:

https://golang.org/pkg/time/#LoadLocation
Leo Famulari May 14, 2021, 1:28 a.m. UTC | #3
On Thu, May 13, 2021 at 08:59:07PM +0200, Stefan Reichör wrote:
> LoadLocation does the lookup in the installed timezone database:
> 
> https://golang.org/pkg/time/#LoadLocation

Oh, I see. This must be why Go itself depends on (and keeps a run-time
reference to) tzdata.

We'll want to fix that someday, but that's a separate concern from these
packages.
jgart Sept. 26, 2021, 8:53 a.m. UTC | #4
Hi,

I didn't realize that Stefan attempted this package already.

Well, here is another attempt from today's Guix Packaging Meetup.

Gábor and I hacked away on tz and it's dependencies a bit.

I tested and built tz with --check --rounds=3 and `guix environment --ad-hoc tz -- tz`

This is a very cool TUI! I use it daily but have had to install it with nix or
build it with golang, depending on what machine I'm on.

Now we can have it in guix.

all best,

jgart

3B1D 7F19 E36B B60C 0F5B 2CA9 A52A A2B4 77B6 DD35
jgart Sept. 26, 2021, 9:12 a.m. UTC | #5
On Sun, 26 Sep 2021 04:53:45 -0400 jgart <jgart@dismail.de> wrote:

I want to give a special shoutout to iskarian‎ ‎and vagrantc‎ for helping me debug
tz over irc.

I was running into some issues with tz not being deterministic at first:

https://paste.sr.ht/~jgart/99583c33249dc7acd35763f9023efc1ec9f8fcd8
jgart Nov. 7, 2021, 7:47 a.m. UTC | #6
0.6.1 is out as of 24 days ago.

https://github.com/oz/tz/releases/tag/v0.6.1
diff mbox series

Patch

diff --git a/gnu/packages/time.scm b/gnu/packages/time.scm
index d6ebb59a1e..fbe7a8b5c1 100644
--- a/gnu/packages/time.scm
+++ b/gnu/packages/time.scm
@@ -19,6 +19,7 @@ 
 ;;; Copyright © 2020 Lars-Dominik Braun <ldb@leibniz-psychology.org>
 ;;; Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
 ;;; Copyright © 2021 Ryan Prior <rprior@protonmail.com>
+;;; Copyright © 2021 Stefan Reichör <stefan@xsteve.at>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -540,3 +541,37 @@  calls.")
 from a starting point you provide.  The user can pause and resume the
 countdown from the text user interface.")
     (license expat)))
+
+(define-public tz
+  (package
+    (name "tz")
+    (version "0.5")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/oz/tz")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1sixfbph5013c9ccx0xqkp9jskg7jr9y29nn9j85q1zmg5by221v"))))
+    (build-system go-build-system)
+    (arguments
+     '(#:import-path "github.com/oz/tz"))
+    (native-inputs
+     `(("go-github-com-charmbracelet-bubbletea" ,go-github-com-charmbracelet-bubbletea)
+       ("go-github-com-containerd-console" ,go-github-com-containerd-console)
+       ("go-github-com-google-goterm" ,go-github-com-google-goterm)
+       ("go-github-com-mattn-go-isatty" ,go-github-com-mattn-go-isatty)
+       ("go-github.com-mattn-go-runewidth" ,go-github.com-mattn-go-runewidth)
+       ("go-github-com-muesli-reflow-ansi" ,go-github-com-muesli-reflow-ansi)
+       ("go-github-com-muesli-reflow-truncate" ,go-github-com-muesli-reflow-truncate)
+       ("go-github-com-muesli-termenv" ,go-github-com-muesli-termenv)
+       ("go-golang-org-colorful" ,go-golang-org-colorful)
+       ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)))
+    (home-page "https://github.com/oz/tz")
+    (synopsis "Display time across a few selected time zones.")
+    (description
+     "tz is a cli tool that displays a given time in several time zones.  Use
+the environment variable TZ_LIST to specify a list of time zones.")
+    (license gpl3)))