diff --git a/Makefile b/Makefile index 85167f3..a084126 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ install: go get github.com/ewhal/pygments go get github.com/go-sql-driver/mysql go get github.com/gorilla/mux + go get github.com/ChannelMeter/iso8601duration test: install go test $(GOFLAGS) ./... diff --git a/assets/clone.html b/assets/clone.html index a9c118a..cefb64d 100644 --- a/assets/clone.html +++ b/assets/clone.html @@ -451,12 +451,13 @@ diff --git a/assets/index.html b/assets/index.html index 3d7ac55..50914ed 100644 --- a/assets/index.html +++ b/assets/index.html @@ -450,12 +450,13 @@ diff --git a/pastebin.go b/pastebin.go index 7302dec..a02420b 100644 --- a/pastebin.go +++ b/pastebin.go @@ -16,6 +16,7 @@ import ( "net/http" "time" + duration "github.com/channelmeter/iso8601duration" // uniuri is used for easy random string generation "github.com/dchest/uniuri" // pygments is used for syntax highlighting @@ -136,8 +137,15 @@ func Save(raw string, lang string, title string, expiry string) Response { } const timeFormat = "2006-01-02 15:04:05" - duration, err := time.ParseDuration(expiry) - Check(err) + + expiry = "P" + expiry + dura, err := duration.FromString(expiry) // dura is time.Duration type + + if err != nil { + fmt.Println("Error : ", err) + } + + duration := dura.ToDuration() expiryTime := time.Now().Add(duration).Format(timeFormat) delKey := uniuri.NewLen(40)