mirror of https://github.com/statping/statping
				
				
				
			
		
			
				
	
	
		
			25 lines
		
	
	
		
			442 B
		
	
	
	
		
			Go
		
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			442 B
		
	
	
	
		
			Go
		
	
	
package utils
 | 
						|
 | 
						|
import (
 | 
						|
	"github.com/hako/durafmt"
 | 
						|
	"time"
 | 
						|
)
 | 
						|
 | 
						|
// Now returns the UTC timestamp
 | 
						|
func Now() time.Time {
 | 
						|
	return time.Now().UTC()
 | 
						|
}
 | 
						|
 | 
						|
type Duration struct {
 | 
						|
	time.Duration
 | 
						|
}
 | 
						|
 | 
						|
func (d Duration) Human() string {
 | 
						|
	return durafmt.Parse(d.Duration).LimitFirstN(2).String()
 | 
						|
}
 | 
						|
 | 
						|
// FormatDuration converts a time.Duration into a string
 | 
						|
func FormatDuration(d time.Duration) string {
 | 
						|
	return durafmt.ParseShort(d).LimitFirstN(3).String()
 | 
						|
}
 |