Categorygithub.com/aaronland/go-world-clock
modulepackage
0.0.0-20221103003751-ba4d0c9e509e
Repository: https://github.com/aaronland/go-world-clock.git
Documentation: pkg.go.dev

# README

go-world-clock

There are many world clocks. This one is mine.

Documentation

Documentation is in progress and incomplete at this time.

Go Reference

Usage

import (
	"github.com/aaronland/go-world-clock"
	"log"
        "time"
)

func main(){

	now := time.Now()
	here := now.Local()

	filters := &clock.Filters{
		Timezones: []string{ "Montreal" },
	}

	results, _ := clock.Time(ctx, here, filters)

	for _, r := range results {
		log.Printf("%s %s\n", r.Timezone, r.Time.Format(time.RFC3339))
	}
}

Tools

time

Print the local time as well as the time in one or more timezones.

$> ./bin/time -h
Print the local time as well as the time in one or more timezones.

Usage:
	 ./bin/time [options]

Valid options are:
  -date string
    	YYYY-MM-dd HH:mm. If empty the current time in the computer's locale will be used.
  -in value
    	Zero or more strings to test whether they are contained by a given timezone's longform (major/minor) label.
  -timezone string
    	A valid major/minor timezone location. Required if -date is not empty.

Example:

$> ./bin/time  -in Melbourne -in Cairo -in Honolulu -in China -in Montreal -in London
Pacific/Honolulu         HST	Tuesday    2021-09-14 13:38
šŸ‘‰                       PDT	Tuesday    2021-09-14 16:38 šŸ‘ˆ
America/Montreal         EDT	Tuesday    2021-09-14 19:38
Europe/London            BST	Wednesday  2021-09-15 00:38
Africa/Cairo             EET	Wednesday  2021-09-15 01:38
Australia/Melbourne      AEST	Wednesday  2021-09-15 09:38

Or specifying a custom date in a timezone:

$> ./bin/time  -date '2021-09-15 03:00' -timezone 'Asia/Singapore' -in London -in 'Los_Angeles'
America/Los_Angeles      PDT	Tuesday    2021-09-14 12:00
Europe/London            BST	Tuesday    2021-09-14 20:00
šŸ‘‰                       +08	Wednesday  2021-09-15 03:00 šŸ‘ˆ

# Packages

No description provided by the author
package timezones provides methods for loading timezone information derived from Who's On First data.

# Functions

Time will return zero or more Location records in other timezones for the time defined in source.

# Structs

type Filter provides definitions for filtering timezone results.
type Location contains structured data about the time in a given timezone.