--- src/http/modules/ngx_http_ssi_filter_module.c 2010-11-24 10:31:17.000000000 +0100 +++ ../nginx-0.8.53.patch/src/http/modules/ngx_http_ssi_filter_module.c 2010-11-24 12:40:29.000000000 +0100 @@ -105,6 +105,8 @@ static ngx_int_t ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t gmt); +static ngx_int_t ngx_http_ssi_date_bbcdn_local_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t gmt); static ngx_int_t ngx_http_ssi_preconfiguration(ngx_conf_t *cf); static void *ngx_http_ssi_create_main_conf(ngx_conf_t *cf); static char *ngx_http_ssi_init_main_conf(ngx_conf_t *cf, void *conf); @@ -308,6 +310,9 @@ { ngx_string("date_gmt"), NULL, ngx_http_ssi_date_gmt_local_variable, 1, NGX_HTTP_VAR_NOCACHEABLE, 0 }, + + { ngx_string("date_bbcdn"), NULL, ngx_http_ssi_date_bbcdn_local_variable, 0, + NGX_HTTP_VAR_NOCACHEABLE, 0 }, { ngx_null_string, NULL, NULL, 0, 0, 0 } }; @@ -2644,6 +2649,55 @@ return NGX_OK; } +static ngx_int_t +ngx_http_ssi_date_bbcdn_local_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t gmt) +{ + ngx_http_ssi_ctx_t *ctx; + ngx_time_t *tp; + struct tm tm; + char buf[NGX_HTTP_SSI_DATE_LEN]; + + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + + tp = ngx_timeofday(); + ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module); + + if (ctx == NULL + || (ctx->timefmt.len == sizeof("%s") - 1 + && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's')) + { + v->data = ngx_pnalloc(r->pool, NGX_TIME_T_LEN); + if (v->data == NULL) { + return NGX_ERROR; + } + v->len = ngx_sprintf(v->data, "%T", tp->sec-(tp->sec % 60)) - v->data; + return NGX_OK; + } + + if (gmt) { + ngx_libc_gmtime(tp->sec - (tp->sec%60), &tm); + } else { + ngx_libc_localtime(tp->sec - (tp->sec%60), &tm); + } + v->len = strftime(buf, NGX_HTTP_SSI_DATE_LEN, + (char *) ctx->timefmt.data, &tm); + if (v->len == 0) { + return NGX_ERROR; + } + + v->data = ngx_pnalloc(r->pool, v->len); + if (v->data == NULL) { + return NGX_ERROR; + } + + ngx_memcpy(v->data, buf, v->len); + return NGX_OK; +} + + static ngx_int_t ngx_http_ssi_preconfiguration(ngx_conf_t *cf)