str2date

From DavinciWiki
Jump to: navigation, search

Description

Returns date/time array corresponding to input string, which must follow the format used by the THEMIS database ("YYYY-MM-DDThh:mm:ss.fff")

Arguments and Return Values

Parameters: A string with the format used by the THEMIS database, and an optional second input specifying a time zone

Return Value: A single-precision (float) date/time array of the same format used by the clock function

Usage

Syntax: str2date("YYYY-MM-DDThh:mm:ss.fff", TZO)

The input must be a string with a length of 23 characters, using the format "YYYY-MM-DDThh:mm:ss.fff", where YYYY is the year, MM is the month, DD is the day, T is simply a character to denote the start of the time section, hh is the hour (24-hour format), mm is the minute, ss is the second, and fff is the number of milliseconds. This format must be strictly followed, or the function will return an error message. Use leading zeroes when necessary.

A second input, which must be scalar and numeric, can be given to specify the time zone offset of the input. If omitted, the function assumes the time zone offset is zero (UTC).

The function uses checkdate and checktime to determine whether the input represents a valid date and time.

This function returns an array of the same format used by clock: [year, month, day, hour, minute, second, time zone offset].

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

Examples

dv> str2date()

Converts input string to date/time array
Input string should have format used by THEMIS database,
 which is "YYYY-MM-DDThh:mm:ss.fff"
Optional second input to specify time zone of input time;
 if no second input given, function assumes UTC
S.Marshall 06-02-2010

0
dv> str2date("2010-01-01T12:34:56.789")
7x1x1 array of float, bsq format [28 bytes]
2010.000        1.000        1.000        12.000        34.000    56.789        0.000
dv> str2date("2010-01-01T12:34:56.789", -7)
7x1x1 array of float, bsq format [28 bytes]
2010.000        1.000        1.000        12.000        34.000    56.789        -7.000
dv> str2date("2010-01-01T12:34:56", -7)

Error! String should be 23 characters!

0

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

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

All other topics

  • See navigation on the left

Related Functions

Recent Library Changes

Created On: 11-18-2009
Modified On: 06-02-2010

Personal tools