src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

commit dc3e5acc59f3c37a86098aa9484e28efd0d49010
parent cc703aded3f352760a56c4b79e5600614fe9ffaa
Author: dwrz <dwrz@dwrz.net>
Date:   Tue, 27 Feb 2024 13:40:19 +0000

Add sun output time format flag

Diffstat:
Mcmd/sun/main.go | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/cmd/sun/main.go b/cmd/sun/main.go @@ -16,6 +16,7 @@ var ( coordinates = flag.String("c", "", "coordinates") date = flag.String("d", "", "date in YYYY-MM-DD format") tz = flag.String("z", "", "timezone") + f = flag.String("f", "", "output time format") ) func main() { @@ -53,8 +54,15 @@ func main() { now.Year(), now.Month(), now.Day(), ) - fmt.Println( - rise.In(loc).Format(time.RFC3339), - set.In(loc).Format(time.RFC3339), - ) + if *f == "" { + fmt.Println( + rise.In(loc).Format(time.RFC3339), + set.In(loc).Format(time.RFC3339), + ) + } else { + fmt.Println( + rise.In(loc).Format(*f), + set.In(loc).Format(*f), + ) + } }