fix up expiry
This commit is contained in:
parent
99bcfa067f
commit
e86b94784d
1
Makefile
1
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) ./...
|
||||
|
@ -451,12 +451,13 @@
|
||||
</select>
|
||||
|
||||
<select id="expiry" name="expiry" class="form-control">
|
||||
<option value="1h">1 hour</option>
|
||||
<option value="24h">1 day</option>
|
||||
<option value="1w">1 week</option>
|
||||
<option value="1m">1 month</option>
|
||||
<option value="12m">1 year</option>
|
||||
<option value="240m" selected>Forever</option>
|
||||
<option value="5M">5 minutes</option>
|
||||
<option value="1H">1 hour</option>
|
||||
<option value="1D">1 day</option>
|
||||
<option value="1W">1 week</option>
|
||||
<option value="30D">1 month</option>
|
||||
<option value="1Y">1 year</option>
|
||||
<option value="20Y" selected>Forever</option>
|
||||
</select>
|
||||
|
||||
<button type="submit" class="btn btn-raised btn-primary">Submit<div class="ripple-container"></div></button>
|
||||
|
@ -450,12 +450,13 @@
|
||||
</select>
|
||||
|
||||
<select id="expiry" name="expiry" class="form-control">
|
||||
<option value="1h">1 hour</option>
|
||||
<option value="24h">1 day</option>
|
||||
<option value="1w">1 week</option>
|
||||
<option value="1m">1 month</option>
|
||||
<option value="12m">1 year</option>
|
||||
<option value="240m" selected>Forever</option>
|
||||
<option value="5M">5 minutes</option>
|
||||
<option value="1H">1 hour</option>
|
||||
<option value="1D">1 day</option>
|
||||
<option value="1W">1 week</option>
|
||||
<option value="30d">1 month</option>
|
||||
<option value="1Y">1 year</option>
|
||||
<option value="20Y" selected>Forever</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-raised btn-primary">Submit<div class="ripple-container"></div></button>
|
||||
</div>
|
||||
|
12
pastebin.go
12
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)
|
||||
|
Loading…
Reference in New Issue
Block a user