From dace4441ae00990e325a1a9140430a08529342e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Zywert?= Date: Fri, 29 Mar 2024 11:44:32 +0100 Subject: [PATCH] dont use first day from next month for month range (#8) * dont use first day from next month for month range * release info --- CHANGELOG.md | 7 ++++++- gojira/utils.go | 4 ++-- gojira/worklog.go | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a97983e..6fc18ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +## [0.5.4] - 2024-03-29 +### Fixed +- MonthRange function returned first day of next month which causes invalid summaries + ## [0.5.3] - 2024-03-27 ### Fixed - calendar controls not working while focus is on latest issues view @@ -85,7 +89,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added - Initial release of gojira -[Unreleased]: https://github.com/jzyinq/gojira/compare/0.5.3...master +[Unreleased]: https://github.com/jzyinq/gojira/compare/0.5.4...master +[0.5.4]: https://github.com/jzyinq/gojira/compare/0.5.3...0.5.4 [0.5.3]: https://github.com/jzyinq/gojira/compare/0.5.2...0.5.3 [0.5.2]: https://github.com/jzyinq/gojira/compare/0.5.1...0.5.2 [0.5.1]: https://github.com/jzyinq/gojira/compare/0.5.0...0.5.1 diff --git a/gojira/utils.go b/gojira/utils.go index 6aa980a..03ec34a 100644 --- a/gojira/utils.go +++ b/gojira/utils.go @@ -114,6 +114,6 @@ func OpenURL(url string) { func MonthRange(t *time.Time) (time.Time, time.Time) { firstDayOfCurrentMonth := time.Date(t.Year(), t.Month(), 1, 0, 0, 0, 0, t.Location()) - firstDayOfNextMonth := firstDayOfCurrentMonth.AddDate(0, 1, 0) - return firstDayOfCurrentMonth, firstDayOfNextMonth + lastDayOfCurrentMonth := firstDayOfCurrentMonth.AddDate(0, 1, 0).Add(-time.Second) + return firstDayOfCurrentMonth, lastDayOfCurrentMonth } diff --git a/gojira/worklog.go b/gojira/worklog.go index d8e7e1b..1f468bd 100644 --- a/gojira/worklog.go +++ b/gojira/worklog.go @@ -112,7 +112,7 @@ func (wl *WorkLogs) TotalTimeSpentToPresentDay() int { if err != nil { logrus.Error(err) } - if logDate.Before(time.Now().Local()) { + if logDate.Before(time.Now().UTC()) { totalTime += log.TimeSpentSeconds } }