hsMkTimestamps: Sequence of Timestamps

View source: R/hsLibDateTime.R

hsMkTimestampsR Documentation

Sequence of Timestamps

Description

Creates timestamps between first timestamp from and to with a distance of step.s seconds between the timestamps. If mdb is given, the timestamps are written to a database table in which the timestamp field is the primary key.

Usage

hsMkTimestamps(from, to, step.s = 60, mdb, tbl, dbg = FALSE)

Arguments

from

first timestamp in ISO-Syntax: yyyy-mm-dd [HH:MM:SS] where the part in brackets is optional.

to

last timestamp in ISO-Syntax: yyyy-mm-dd [HH:MM:SS] where the part in brackets is optional.

step.s

time step between the timestamps in seconds.

mdb

Optional. Full path to MS Access database file (*.mdb).

tbl

Optional. Name of table to be created in mdb. If no name is given a name of the type tblfrom_to_to_step.s_s is created. If a table of given name exists, a non-existing name is generated first, so existing tables will not be overwritten.

dbg

if TRUE, debug messages are shown.

Value

Returns vecotor of timestamps if mdb is missing or nothing if timestamp table has been generated in database given in mdb.

Examples

## Not run: 
## Write timestamps of January 2011 with five minutes step into example db.
hsMkTimestamps("2011-01-01", "2011-02-01", 300, kwb.db::xmdb())

## End(Not run)

## Output:
# Timestamps have been written to table
#   'tblTimestamps_2011_01_01_to_2011_02_01_300s' in
# 'C:/Users/hsonne/Documents/R/win-library/2.14/
#   kwb.base/extdata/RExKwbBase.mdb'.
# Timestamp field has been set as primary key.

KWB-R/kwb.base documentation built on June 19, 2022, 3:30 a.m.