TP-47297 | Slack DM for incident reminder (#276)

* TP-47297 | Slack DM for incident reminder - A cron job to send list of open incidents to every users who are part of it along with their role in it

* Delete common/util/config_util.go

---------

Co-authored-by: Md Anees <md.anees@navi.com>
This commit is contained in:
Shashank Shekhar
2023-11-09 17:38:43 +05:30
committed by GitHub
parent 1125f573b2
commit 0f8c326fe7
10 changed files with 474 additions and 36 deletions

View File

@@ -28,6 +28,25 @@ func RemoveDuplicate[T string | int](sliceList []T) []T {
return list
}
// GetTimeElapsedInDaysAndHours - returns number of days and hours elapsed since the timestamp passed in argument
func GetTimeElapsedInDaysAndHours(timestamp time.Time) (int, int) {
// convert to IST time
locationName := "Asia/Kolkata"
location, err := time.LoadLocation(locationName)
if err != nil {
logger.Error(fmt.Sprintf("failed to load location for locationName %s", locationName))
}
timestampInIST := timestamp.In(location)
currentTimeInIST := time.Now().In(location)
// Calculate the time difference
timeDiff := currentTimeInIST.Sub(timestampInIST)
// Convert the duration into days and hours
days := int(timeDiff.Hours() / 24)
hours := int(timeDiff.Hours()) % 24
return days, hours
}
// Difference : finds difference of two slices and returns a new slice
func Difference(s1, s2 []string) []string {
combinedSlice := append(s1, s2...)