# Ngx\_parse\_time not handling seconds flag properly?

**URL:** <https://www.ruby-forum.com/t/ngx-parse-time-not-handling-seconds-flag-properly/158800>\
**Category:** NGINX\
**Created:** [January 28, 2009, 4:40am UTC](https://www.ruby-forum.com/t/ngx-parse-time-not-handling-seconds-flag-properly/158800 "2009-01-28T04:40:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mschwab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mschwab](https://www.ruby-forum.com/u/mschwab)\
**Post date:** [January 28, 2009, 4:40am UTC](https://www.ruby-forum.com/t/ngx-parse-time-not-handling-seconds-flag-properly/158800/1 "2009-01-28T04:40:48Z")

</div>

It looks to me like ngx\_parse\_time is scaling to seconds when you  
don’t want it and not scaling when you do. When called from  
ngx\_conf\_set\_msec\_slot, it scales all msec values up by a factor of  
1000, so if I want a timeout of 180ms I actually get a timeout of  
180s.

Can anyone comment on this.

Thanks,  
Mike

# Index: src/core/ngx\_parse.c

— src/core/ngx\_parse.c (…/tags/nginx-0.7.32) (revision 15961)  
+++ src/core/ngx\_parse.c (…/trunk/nginx) (revision 15961)  
@@ -115,7 +115,7 @@ ngx\_parse\_time(ngx\_str\_t \*line, ngx\_uint\_t sec)  
value = 0;  
total = 0;  
step = sec ? st\_start : st\_month;

- scale = sec ? 1 : 1000;

- scale = sec ? 1000 : 1;

---

<div class="post-metadata">

**Author:** ![mschwab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mschwab](https://www.ruby-forum.com/u/mschwab)\
**Post date:** [January 28, 2009, 7:58am UTC](https://www.ruby-forum.com/t/ngx-parse-time-not-handling-seconds-flag-properly/158800/2 "2009-01-28T07:58:30Z")

</div>

On Tue, Jan 27, 2009 at 07:29:58PM -0800, Mike S. wrote:

> It looks to me like ngx\_parse\_time is scaling to seconds when you  
> don’t want it and not scaling when you do. When called from  
> ngx\_conf\_set\_msec\_slot, it scales all msec values up by a factor of  
> 1000, so if I want a timeout of 180ms I actually get a timeout of  
> 180s.
> 
> Can anyone comment on this.

nginx works internally with millisecond resolution.  
So ngx\_parse\_time(…, 0) returns parsed time in milliseconds.  
There are some places where seconds are enough, for these  
ngx\_parse\_time(…, 1) returns parsed time in seconds.
