From 99bcfa067f082db70cb551f7cedd7fa3da3b5693 Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Fri, 15 Jul 2016 12:41:42 +1000 Subject: [PATCH] Remove durationfromexpiry function --- pastebin.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pastebin.go b/pastebin.go index 224d08d..7302dec 100644 --- a/pastebin.go +++ b/pastebin.go @@ -104,14 +104,6 @@ func Sha1(paste string) string { return sha } -// DurationFromExpiry takes the expiry in string format and returns the duration -// that the paste will exist for -func DurationFromExpiry(expiry string) time.Duration { - duration, err := time.ParseDuration(expiry) - Check(err) - return duration -} - // Save function handles the saving of each paste. // raw string is the raw paste input // lang string is the user specified language for syntax highlighting @@ -144,7 +136,9 @@ func Save(raw string, lang string, title string, expiry string) Response { } const timeFormat = "2006-01-02 15:04:05" - expiryTime := time.Now().Add(DurationFromExpiry(expiry)).Format(timeFormat) + duration, err := time.ParseDuration(expiry) + Check(err) + expiryTime := time.Now().Add(duration).Format(timeFormat) delKey := uniuri.NewLen(40) dataEscaped := html.EscapeString(raw)