Difference between revisions of "Ns time"
Jump to navigation
Jump to search
(imported from WiKit id 499) |
m (formatting tweaks) |
||
Line 1: | Line 1: | ||
− | + | <manpage>ns_time</manpage> | |
− | |||
− | |||
'''NAME''' | '''NAME''' | ||
Line 14: | Line 12: | ||
: This command provides various time-related functions. The legal ''option''s (which may be abbreviated) are: | : This command provides various time-related functions. The legal ''option''s (which may be abbreviated) are: | ||
+ | |||
* '''ns_time adjust''' ''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.)'' | : 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'' | * '''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. | : 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''' | * '''ns_time get''' | ||
: Returns the current time in "sec:usec" format. | : Returns the current time in "sec:usec" format. | ||
+ | |||
* '''ns_time incr''' ''time sec ?usec?'' | * '''ns_time incr''' ''time sec ?usec?'' | ||
: Increments ''time'' by ''sec'' seconds and optionally ''usec'' microseconds. Returns a string in "sec:usec" format. | : Increments ''time'' by ''sec'' seconds and optionally ''usec'' microseconds. Returns a string in "sec:usec" format. | ||
+ | |||
* '''ns_time make''' ''sec ?usec?'' | * '''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. | : 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'' | * '''ns_time seconds''' ''time'' | ||
: Parses a time in "sec:usec" format and returns the seconds portion. | : Parses a time in "sec:usec" format and returns the seconds portion. | ||
+ | |||
* '''ns_time microseconds''' ''time'' | * '''ns_time microseconds''' ''time'' | ||
Line 79: | Line 84: | ||
: [[ns_fmttime]], [[ns_gmtime]], [[ns_httptime]], [[ns_localtime]], [[ns_parsehttptime]], [[ns_parsetime]] | : [[ns_fmttime]], [[ns_gmtime]], [[ns_httptime]], [[ns_localtime]], [[ns_parsehttptime]], [[ns_parsetime]] | ||
− | |||
− | [[Category | + | [[Category:Core Tcl API]] |
Revision as of 12:26, 3 November 2005
<manpage>ns_time</manpage>
NAME
- ns_time - Perform various time-related functions
SYNOPSIS
- ns_time ?option? ?arg arg ...?
DESCRIPTION
- This command provides various time-related functions. The legal options (which may be abbreviated) are:
- 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.
NOTES
- 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 ns_time get 1087013247:598897
% ns_time seconds $time 1087013247
% ns_time microseconds $time 598897
% set time2 ns_time incr $time 5 30 1087013252:598927
% ns_set diff $time2 $time 5:30
% set time3 ns_time make 1087013240 598890 1087013240:598890
% ns_time diff $time $time3 7:7
% ns_time diff $time3 $time -8:999993
% set time3 ns_time incr $time3 7 7 1087013247:598897
% ns_time diff $time $time3 0
SEE ALSO