~kota/tide

81da496078f88a4df14d7b8a190ba726ec7cac65 — Dakota Walsh 1 year, 4 months ago 576e597
create a constant for the timezone
1 files changed, 3 insertions(+), 1 deletions(-)

M main.go
M main.go => main.go +3 -1
@@ 20,6 20,8 @@ type Tide struct {
	Height float64
}

const tz = "NZ"

func main() {
	// Get a File from Stdin or a passed argument
	f, err := getInput()


@@ 122,7 124,7 @@ func parseRecord(tides *[]Tide, record []string) error {
// getDate takes the year, month, day strings from the CSV file and returns a
// time.Time value with the correct timezone.
func getDate(year, month, day string) (time.Time, error) {
	loc, _ := time.LoadLocation("NZ") // Timezone isn't included in the CSV
	loc, _ := time.LoadLocation(tz) // Timezone isn't included in the CSV
	month = fmt.Sprintf("%02s", month)
	day = fmt.Sprintf("%02s", day)
	t, err := time.ParseInLocation("20060102", year+month+day, loc)