NaviServer Programmable Web Server

ns_baseunit(n)

NaviServer Built-in Commands – 5.2.0a


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

Name

ns_baseunit - Convert time and memory-size units to seconds and bytes

Table Of Contents

Synopsis

Description

COMMANDS

ns_baseunit ?-size memory-size? ?-time time?

Convert a memory size to bytes or a time value to seconds, using the same NaviServer converters used by other commands. Fractional seconds are preserved. This lets Tcl commands accept uniform unit-bearing arguments, for example when calculating cache partition sizes from values such as 2MB.

Either -size memory-size or -time time has to be specified. Valid time units are μs, ms, s, m, h, d, w, y. Valid size units are kB, MB, GB, KiB, MiB, GiB.

EXAMPLES

 % ns_baseunit -size 10KiB
 10240
 
 % ns_baseunit -time 2.5h
 9000
 % ns_baseunit -time 1500ms
 1.5

Keywords

conversion, global built-in, size, time, unit