fixing windows handling of eastern standard time
This commit is contained in:
parent
841f21921e
commit
b9f2a35a5d
3 changed files with 34 additions and 12 deletions
12
date.go
12
date.go
|
@ -208,18 +208,6 @@ func (d date) IsNASDAQHoliday(t time.Time) bool {
|
||||||
return d.IsNYSEHoliday(t)
|
return d.IsNYSEHoliday(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eastern returns the eastern timezone.
|
|
||||||
func (d date) Eastern() *time.Location {
|
|
||||||
if _eastern == nil {
|
|
||||||
_easternLock.Lock()
|
|
||||||
defer _easternLock.Unlock()
|
|
||||||
if _eastern == nil {
|
|
||||||
_eastern, _ = time.LoadLocation("America/New_York")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _eastern
|
|
||||||
}
|
|
||||||
|
|
||||||
// Time returns a new time.Time for the given clock components.
|
// Time returns a new time.Time for the given clock components.
|
||||||
func (d date) Time(hour, min, sec, nsec int, loc *time.Location) time.Time {
|
func (d date) Time(hour, min, sec, nsec int, loc *time.Location) time.Time {
|
||||||
return time.Date(0, 0, 0, hour, min, sec, nsec, loc)
|
return time.Date(0, 0, 0, hour, min, sec, nsec, loc)
|
||||||
|
|
17
date_posix.go
Normal file
17
date_posix.go
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package chart
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Eastern returns the eastern timezone.
|
||||||
|
func (d date) Eastern() *time.Location {
|
||||||
|
if _eastern == nil {
|
||||||
|
_easternLock.Lock()
|
||||||
|
defer _easternLock.Unlock()
|
||||||
|
if _eastern == nil {
|
||||||
|
_eastern, _ = time.LoadLocation("America/New_York")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _eastern
|
||||||
|
}
|
17
date_windows.go
Normal file
17
date_windows.go
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// +build windows
|
||||||
|
|
||||||
|
package chart
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Eastern returns the eastern timezone.
|
||||||
|
func (d date) Eastern() *time.Location {
|
||||||
|
if _eastern == nil {
|
||||||
|
_easternLock.Lock()
|
||||||
|
defer _easternLock.Unlock()
|
||||||
|
if _eastern == nil {
|
||||||
|
_eastern, _ = time.LoadLocation("Eastern Standard Time")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _eastern
|
||||||
|
}
|
Loading…
Reference in a new issue