Use parseduration
This commit is contained in:
parent
5242324a60
commit
277cfdefff
|
@ -451,12 +451,12 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="expiry" name="expiry" class="form-control">
|
<select id="expiry" name="expiry" class="form-control">
|
||||||
<option value="1">1 hour</option>
|
<option value="1h">1 hour</option>
|
||||||
<option value="24">1 day</option>
|
<option value="24h">1 day</option>
|
||||||
<option value="24 * 7">1 week</option>
|
<option value="1w">1 week</option>
|
||||||
<option value="24 * 30">1 month</option>
|
<option value="1m">1 month</option>
|
||||||
<option value="24 * 365">1 year</option>
|
<option value="12m">1 year</option>
|
||||||
<option value="24 * (20 * 365)" selected>Forever</option>
|
<option value="240m" selected>Forever</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-raised btn-primary">Submit<div class="ripple-container"></div></button>
|
<button type="submit" class="btn btn-raised btn-primary">Submit<div class="ripple-container"></div></button>
|
||||||
|
|
|
@ -450,12 +450,12 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="expiry" name="expiry" class="form-control">
|
<select id="expiry" name="expiry" class="form-control">
|
||||||
<option value="1">1 hour</option>
|
<option value="1h">1 hour</option>
|
||||||
<option value="24">1 day</option>
|
<option value="24h">1 day</option>
|
||||||
<option value="24 * 7">1 week</option>
|
<option value="1w">1 week</option>
|
||||||
<option value="24 * 30">1 month</option>
|
<option value="1m">1 month</option>
|
||||||
<option value="24 * 365">1 year</option>
|
<option value="12m">1 year</option>
|
||||||
<option value="24 * (20 * 365)" selected>Forever</option>
|
<option value="240m" selected>Forever</option>
|
||||||
</select>
|
</select>
|
||||||
<button type="submit" class="btn btn-raised btn-primary">Submit<div class="ripple-container"></div></button>
|
<button type="submit" class="btn btn-raised btn-primary">Submit<div class="ripple-container"></div></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
// uniuri is used for easy random string generation
|
// uniuri is used for easy random string generation
|
||||||
|
@ -108,9 +107,9 @@ func Sha1(paste string) string {
|
||||||
// DurationFromExpiry takes the expiry in string format and returns the duration
|
// DurationFromExpiry takes the expiry in string format and returns the duration
|
||||||
// that the paste will exist for
|
// that the paste will exist for
|
||||||
func DurationFromExpiry(expiry string) time.Duration {
|
func DurationFromExpiry(expiry string) time.Duration {
|
||||||
i, err := strconv.ParseInt(expiry, 10, 64)
|
duration, err := time.ParseDuration(expiry)
|
||||||
Check(err)
|
Check(err)
|
||||||
return time.Hour * time.Duration(i)
|
return duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save function handles the saving of each paste.
|
// Save function handles the saving of each paste.
|
||||||
|
|
Loading…
Reference in New Issue