Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 Group: Handling of time Topic: Generating timepoints See also: settimegran settimezero getnow getlocalnow

 Function: settime Description: settime generates from a set of vectors a vector of time points. The parameter yr (year) is necessary, the parameters mo (month), dy (day of month), hr (hour), mn (minute), sc (second) are optional. The granulation of the measurement can be changed with the command settimegran. Each value in the produced set of vectors describes the distance to a fixed point in time (usually 1.1.1900 0:00:00.0). The zero time can be changed with the command settimezero. The following example teaches you to be careful not to span too much time with a too small granulation (some kind of overflow/underflow problem).

 Usage: t = settime (yr {, mo {, dy {, hr {, mn {, sc}}}}}}) Input: yr n x 1 vector mo n x 1 vector dy n x 1 vector hr n x 1 vector mn n x 1 vector sc n x 1 vector Output: t n x 1 time vector

Example:
; sets year to 1901, ..., 2038
yr = #(1901, 1902, 2037, 2038)
; Date  9th Oct, Time: 5 min 32 sec after midnight
mo = 10*matrix(rows(yr))
dy =  9*matrix(rows(yr))
hr =  0*matrix(rows(yr))
mi =  5*matrix(rows(yr))
sc = 32*matrix(rows(yr))
t  = settime(yr, mo, dy, hr, mi, sc)
; check dates
st = dayofmonth(t) +"."+month(t)+"."+year(t)+" "+hour(t)+":"+minute(t)+":"+second(t)
; Note that the output generated is not as you might have expected. You have
; to be aware that you cannot span too many time points.
; In this particular case, you can just span time points from 1902 till 2037.
st

Result:
Contents of st

[1,] "14.Nov.2037 06:33:48"

[2,] "09.Oct.1902 00:05:32"

[3,] "09.Oct.2037 00:05:32"

[4,] "02.Sep.1902 17:37:16"

(C) MD*TECH Method and Data Technologies, 05.02.2006