Skip to content

A golang helper to determine if a time in a location is in daylight savings time or not.

Notifications You must be signed in to change notification settings

ace-teknologi/isdst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

isdst

A golang helper to determine if a time in a location is in daylight savings time or not.

Why?

Unlike other languages, go doesn't expose the ability to determine if the time is in DST or not.

See proposal: time: add Time.IsDST() bool method #42102

How to use?

package main

import (
	"fmt"
	"time"

	"github.com/ace-teknologi/isdst"
)

func main() {
	loc, _ := time.LoadLocation("Australia/Broken_Hill")

	// DST
	t := time.Date(2020, time.January, 1, 0, 0, 0, 0, loc)
	fmt.Printf("Is daylight savings? %t", isdst.IsDST(t))

	// Non-DST
	t := time.Date(2020, time.June, 1, 0, 0, 0, 0, loc)
	fmt.Printf("Is daylight savings? %t", isdst.IsDST(t))
}

About

A golang helper to determine if a time in a location is in daylight savings time or not.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages