[master] f6ef923 Add a 'y'ear conversion factor to std.duration().

Poul-Henning Kamp phk at FreeBSD.org
Mon May 5 13:51:29 CEST 2014


commit f6ef923b2155b323f5182eeae2d4423796cd35b9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 5 11:50:39 2014 +0000

    Add a 'y'ear conversion factor to std.duration().
    
    Submitted by:	github::brianjarita

diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc
index 53f5ae3..5ef9dde 100644
--- a/bin/varnishtest/tests/m00005.vtc
+++ b/bin/varnishtest/tests/m00005.vtc
@@ -97,4 +97,10 @@ client c1 {
 	expect resp.http.ttl == 1000002.000
 	expect resp.bodylen == 1
 
+	txreq -url "/1"  -hdr "ttl: 1y"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.ttl == 32536001.000
+	expect resp.bodylen == 1
+
 } -run
diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c
index b9020d1..f98b5fb 100644
--- a/lib/libvmod_std/vmod_std_conversions.c
+++ b/lib/libvmod_std/vmod_std_conversions.c
@@ -86,6 +86,7 @@ vmod_duration(const struct vrt_ctx *ctx, const char *p, VCL_DURATION d)
 	case 'h': r *= 60.*60.; break;
 	case 'd': r *= 60.*60.*24.; break;
 	case 'w': r *= 60.*60.*24.*7.; break;
+	case 'y': r *= 60.*60.*24.*365.; break;
 	default:
 		return (d);
 	}



More information about the varnish-commit mailing list