[ Table Of Contents | Keyword Index ]

ns_time(n) 4.99 "NaviServer Built-in Commands"

NAME

ns_time - Perform various time-related functions

TABLE OF CONTENTS

    TABLE OF CONTENTS
    SYNOPSIS
    DESCRIPTION
    COMMANDS
    EXAMPLES
    SEE ALSO
    KEYWORDS

SYNOPSIS

ns_time ?arg arg ...?
ns_time adjust time
ns_time diff time1 time2
ns_time get
ns_time incr time sec ?usec?
ns_time make sec ?usec?
ns_time seconds time
ns_time microseconds time

DESCRIPTION

This command provides various time-related functions. The legal options (which may be abbreviated) are:

COMMANDS

ns_time ?arg arg ...?
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 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 in "sec:usec" format and returns the seconds portion.

ns_time microseconds time
Parses a time in "sec:usec" format and returns the microseconds portion. It assumes zero microseconds if time only contains seconds. All times are relative to 00:00:00 UTC, January 1, 1970 aka the Unix epoch. ns_time called with no option returns the current time in seconds.

EXAMPLES

 
   % ns_time
   1087006685

 
   % set time 
   1087013247:598897

 
   % ns_time diff $time $time3
   0

SEE ALSO

nsd

KEYWORDS

ns_fmttime , ns_gmtime , ns_httptime , ns_localtime , ns_parsehttptime , ns_parsetime