NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_time(n) 5.0.0a naviserver "NaviServer Built-in Commands"

Name

ns_time - Perform various time-related functions

Table Of Contents

Synopsis

Description

This command provides various time-related functions. Times might be of the form "sec" (integer value), "sec:usec" (NaviServer internal format) or "sec.fraction"

All time arguments can be specified in the form secs?:microsecs?, or secs.fraction, or as a number with a time unit. Valid time units are μs, ms, s, m, h, d, w, y.

COMMANDS

ns_time ?arg arg ...?
ns_time

Returns the seconds portion of the current time.

ns_time adjust time

Adjusts time so that it is within the valid range of values for a time. (TODO: Figure out how this is actually useful.)

ns_time diff time1 time2

Computes the time difference between time1 to time2. It does this by subtracting time1 from time2 and returns a string in "sec:usec" format.

ns_time format time

Returns the time in seconds in the form of a real number.

ns_time get

Returns the current time in "sec:usec" format.

ns_time incr time sec ?usec?

Increments time by sec seconds and optionally usec microseconds. Returns a string in "sec:usec" format.

ns_time make sec ?usec?

Returns a string in the form "sec:usec". usec defaults to zero. If usec is zero, the colon and usec are not returned. If sec is zero, however, it is returned as part of the time string.

ns_time seconds time

Parses a time and returns the seconds portion.

ns_time microseconds time

Parses a time and returns the microseconds portion. It assumes zero microseconds if time only contains seconds.

EXAMPLES

 % ns_time
 1087006685
 % ns_time get
 1087013247:598897
 % set t [ns_time diff $time $time3]
 0:13
 
 % ns_time format $t
 0.000013

See Also

ns_fmttime, ns_gmtime, ns_httptime, ns_localtime, ns_parsehttptime, ns_parsetime, ns_sleep

Keywords

global built-in, time, timeunit