Skip to content

Commit

Permalink
feat: timezone: init
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Jan 27, 2021
1 parent 9152ef5 commit 16906a9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions time/timezone/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// timezone is a static list of timezones. It is incomplete as of now.
// Eventually it will be autogenerated using the approach as shown
// here: https://stackoverflow.com/questions/40120056/get-a-list-of-valid-time-zones-in-go
package timezone

const (
TimezoneAmericaChicago = "America/Chicago"
TimezoneAmericaLosAngeles = "America/Los_Angeles"
)
38 changes: 38 additions & 0 deletions time/timezone/examples/build_constants/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// main this code was sourced from Stack Overflow here:
// https://stackoverflow.com/a/40130882/1908967
package main

import (
"fmt"
"io/ioutil"
"strings"
)

var zoneDirs = []string{
// Update path according to your OS
"/usr/share/zoneinfo/",
"/usr/share/lib/zoneinfo/",
"/usr/lib/locale/TZ/",
}

var zoneDir string

func main() {
for _, zoneDir = range zoneDirs {
ReadFile("")
}
}

func ReadFile(path string) {
files, _ := ioutil.ReadDir(zoneDir + path)
for _, f := range files {
if f.Name() != strings.ToUpper(f.Name()[:1])+f.Name()[1:] {
continue
}
if f.IsDir() {
ReadFile(path + "/" + f.Name())
} else {
fmt.Println((path + "/" + f.Name())[1:])
}
}
}

0 comments on commit 16906a9

Please sign in to comment.