https://github.com/coreos/etcd
Raw File
Tip revision: 49e0dff2b8529801beb09164729caf96a5b93ef0 authored by Yicheng Qin on 29 July 2014, 17:31:48 UTC
CHANGELOG: v0.4.6
Tip revision: 49e0dff
ttl.go
package store

import (
	"strconv"
	"time"
)

// Convert string duration to time format
func TTL(duration string) (time.Time, error) {
	if duration != "" {
		duration, err := strconv.Atoi(duration)
		if err != nil {
			return Permanent, err
		}
		return time.Now().Add(time.Second * (time.Duration)(duration)), nil

	} else {
		return Permanent, nil
	}
}
back to top