@@ -22,7 +22,7 @@ import "time"
2222// now := time.Now()
2323// startOfDay := BeginOfDay(now) // This will set the time to midnight of the current day.
2424func BeginOfDay (v time.Time ) time.Time {
25- return time .Date (v .Year (), v .Month (), v .Day (), 0 , 0 , 0 , 0 , v .Local (). Location ())
25+ return time .Date (v .Year (), v .Month (), v .Day (), 0 , 0 , 0 , 0 , v .Location ())
2626}
2727
2828// FEndOfDay takes a time value `v` and returns a new time.Time object
@@ -46,7 +46,7 @@ func BeginOfDay(v time.Time) time.Time {
4646// now := time.Now()
4747// endOfDay := FEndOfDay(now) // This will set the time to the last second of the current day.
4848func FEndOfDay (v time.Time ) time.Time {
49- return time .Date (v .Year (), v .Month (), v .Day (), 23 , 59 , 59 , 0 , v .Local (). Location ())
49+ return time .Date (v .Year (), v .Month (), v .Day (), 23 , 59 , 59 , 0 , v .Location ())
5050}
5151
5252// PrevBeginOfDay takes a time value `v` and an integer `day` representing the number of days to go back.
@@ -125,8 +125,11 @@ func PrevEndOfDay(v time.Time, day int) time.Time {
125125// nyTime, err := SetTimezone(now, "America/New_York") // This will convert the current time to New York's timezone.
126126func SetTimezone (v time.Time , tz string ) (time.Time , error ) {
127127 loc , err := time .LoadLocation (tz )
128+ if err != nil {
129+ return v , err
130+ }
128131 now := v .In (loc )
129- return now , err
132+ return now , nil
130133}
131134
132135// AdjustTimezone takes a time value `v` and a string `tz` representing the target timezone,
0 commit comments