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:
@@ -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...)
|
||||
|
||||
Reference in New Issue
Block a user