clock

From DavinciWiki
Jump to: navigation, search

Description

Returns array giving current system time

Arguments and Return Values

Parameters: One scalar input specifying the format to return

Return Value: A 7x1x1 numeric array

Usage

Syntax: clock(mode)

The input must be scalar.

The behavior of this function and the format and precision of its output depend on the operating system on which Davinci is being run, since this function does a system call. The output is only as accurate as your system clock.

Regardless of operating system, if the input is zero, the returned array will be integer format.

In Linux/Unix, if given a nonzero input, the function will return a double-precision array, with the seconds precise to one microsecond (1e-6 s).

In Windows, the function has to ask you for your time zone (only the first time in a session you call it). If given a nonzero input, the function will return a single-precision (float) array, with the seconds precise to one hundredth of a second.

In Mac, the function returns an integer array regardless of the input, since it can only get the integer number of seconds from the terminal.

If the offset (in hours) between your time zone and UTC is a non-integer number of hours, the returned array will be float (in Mac or Windows) or double (in Unix/Linux), regardless of input argument, in order to display the time zone accurately.

The elements of the returned array, in order: year, month, day, hour, minute, second, local time zone

The returned array gives the local time and the local time zone offset from UTC. Currently there is no option to return UTC time.

When clock() is entered without any arguments, it prints its description, as shown below.

Examples

In Linux:

dv> clock()

Returns array of current system clock information
clock(mode) returns [year, month, day, hour, minute, second, timezone]
 timezone is time zone offset (local - UTC), in hours
 mode = 0 to return integer array
 mode = anything else to return float (in Windows) or double (in
  Unix) array
 In Mac, only integers are returned, unless you're in a non-integer time
  zone, since the Mac terminal doesn't return fraction of seconds.
S.Marshall 11-20-2009

0
dv> clock(0)
7x1x1 array of int, bsq format [28 bytes]
2009    11      20      16      32      35      -7
dv> clock(1)
7x1x1 array of double, bsq format [56 bytes]
2009.00000000000        11.0000000000000        20.0000000000000        16.0000000000000
32.0000000000000        36.6539270000000      -7.00000000000000

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Major Sub-Functions

Related Functions

Recent Library Changes

Created On: 11-18-2009
Modified On: 12-09-2010

Personal tools