lots of changes
This commit is contained in:
parent
0e849b11bb
commit
a7ff82d63f
|
@ -61,10 +61,10 @@ func (d date) MustEastern() *time.Location {
|
||||||
func (d date) Eastern() (*time.Location, error) {
|
func (d date) Eastern() (*time.Location, error) {
|
||||||
// Try POSIX
|
// Try POSIX
|
||||||
est, err := time.LoadLocation("America/New_York")
|
est, err := time.LoadLocation("America/New_York")
|
||||||
if err == nil {
|
if err != nil {
|
||||||
// Try Windows
|
// Try Windows
|
||||||
est, err = time.LoadLocation("EST")
|
est, err = time.LoadLocation("EST")
|
||||||
if err == nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,10 +83,10 @@ func (d date) MustPacific() *time.Location {
|
||||||
func (d date) Pacific() (*time.Location, error) {
|
func (d date) Pacific() (*time.Location, error) {
|
||||||
// Try POSIX
|
// Try POSIX
|
||||||
pst, err := time.LoadLocation("America/Los_Angeles")
|
pst, err := time.LoadLocation("America/Los_Angeles")
|
||||||
if err == nil {
|
if err != nil {
|
||||||
// Try Windows
|
// Try Windows
|
||||||
pst, err = time.LoadLocation("PST")
|
pst, err = time.LoadLocation("PST")
|
||||||
if err == nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,13 @@ func parse(v string) time.Time {
|
||||||
return ts
|
return ts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDateEastern(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
eastern, err := Date.Eastern()
|
||||||
|
assert.Nil(err)
|
||||||
|
assert.NotNil(eastern)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDateTime(t *testing.T) {
|
func TestDateTime(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
@ -36,7 +43,10 @@ func TestDateDate(t *testing.T) {
|
||||||
func TestDateOnDate(t *testing.T) {
|
func TestDateOnDate(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
ts := Date.OnDate(Date.Time(5, 4, 3, 2, time.UTC), Date.Date(2016, 6, 7, Date.MustEastern()))
|
eastern := Date.MustEastern()
|
||||||
|
assert.NotNil(eastern)
|
||||||
|
|
||||||
|
ts := Date.OnDate(Date.Time(5, 4, 3, 2, time.UTC), Date.Date(2016, 6, 7, eastern))
|
||||||
assert.Equal(2016, ts.Year())
|
assert.Equal(2016, ts.Year())
|
||||||
assert.Equal(6, ts.Month())
|
assert.Equal(6, ts.Month())
|
||||||
assert.Equal(7, ts.Day())
|
assert.Equal(7, ts.Day())
|
||||||
|
|
|
@ -24,9 +24,9 @@ func (tu timeUtil) DiffDays(t1, t2 time.Time) (days int) {
|
||||||
t2n := t2.Unix()
|
t2n := t2.Unix()
|
||||||
var diff int64
|
var diff int64
|
||||||
if t1n > t2n {
|
if t1n > t2n {
|
||||||
diff = t2n - t1n //yields seconds
|
|
||||||
} else {
|
|
||||||
diff = t1n - t2n //yields seconds
|
diff = t1n - t2n //yields seconds
|
||||||
|
} else {
|
||||||
|
diff = t2n - t1n //yields seconds
|
||||||
}
|
}
|
||||||
return int(diff / (_secondsPerDay))
|
return int(diff / (_secondsPerDay))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user