add: timer

This commit is contained in:
vilet.yy 2021-06-10 14:49:46 +08:00
parent 18549b22db
commit 970cfd6b73
1 changed files with 24 additions and 0 deletions

24
timer/time.go Normal file
View File

@ -0,0 +1,24 @@
/*
* @Date: 2021-06-10 14:41:54
* @LastEditors: viletyy
* @LastEditTime: 2021-06-10 14:46:39
* @FilePath: /yolk/timer/time.go
*/
package timer
import "time"
func GetNowTime() time.Time {
location, _ := time.LoadLocation("Asia/Shanghai")
return time.Now().In(location)
}
func GetCalculateTime(currentTimer time.Time, d string) (time.Time, error) {
duration, err := time.ParseDuration(d)
if err != nil {
return time.Time{}, err
}
return currentTimer.Add(duration), nil
}