Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #80 from scottleedavis/issue_71
Browse files Browse the repository at this point in the history
Fixes Issue #71
  • Loading branch information
scottleedavis authored Apr 28, 2019
2 parents c87b1b7 + 61b028b commit fc9b260
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "com.github.scottleedavis.mattermost-plugin-remind",
"name": "Remind Bot Mattermost Plugin",
"description": "Sets Reminders",
"version": "0.1.7",
"version": "0.1.8",
"server": {
"executables": {
"linux-amd64": "server/dist/plugin-linux-amd64",
Expand Down
2 changes: 1 addition & 1 deletion server/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ var manifest = struct {
Version string
}{
Id: "com.github.scottleedavis.mattermost-plugin-remind",
Version: "0.1.7",
Version: "0.1.8",
}
1 change: 0 additions & 1 deletion server/occurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ func (p *Plugin) atEN(when string, user *model.User) (times []time.Time, err err

now := time.Now().In(location).Round(time.Hour * time.Duration(24))
occurrence := t.AddDate(now.Year(), int(now.Month())-1, now.Day()-1)

return []time.Time{p.chooseClosest(user, &occurrence, true).UTC()}, nil

}
Expand Down
25 changes: 15 additions & 10 deletions server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@ func (p *Plugin) translation(user *model.User) (i18n.TranslateFunc, string) {
}

func (p *Plugin) location(user *model.User) *time.Location {
tz_code := user.GetPreferredTimezone()
if tz_code == "" {
tz_code, _ = time.Now().Zone()
}
if tzLoc, err := timezone.GetTimezones(tz_code); err != nil {
return time.Now().Location()
} else {
if l, lErr := time.LoadLocation(tzLoc[0]); lErr != nil {
tz := user.GetPreferredTimezone()
if tz == "" {
tzCode, _ := time.Now().Zone()

if tzLoc, err := timezone.GetTimezones(tzCode); err != nil {
return time.Now().Location()
} else {
return l
}
if l, lErr := time.LoadLocation(tzLoc[0]); lErr != nil {
return time.Now().Location()
} else {
return l
}

}
} else {
location, _ := time.LoadLocation(tz)
return location
}

}

0 comments on commit fc9b260

Please sign in to comment.