Algosim documentation: ParseTime

ParseTime

Parses a string as a time.

Syntax

Description

ParseTime(s) attempts to parse the string s as a time and returns, if successful, this time as a Time structure. The function assumes that the fields of the time are specified in the hour, minute, second, millisecond order and does not require that all fields are specified. Instead, the numeric fields in s are identified from left to right and used in that order to assign the hour, minute, second, and millisecond fields of the result until there are no numeric fields left in s. Time fields left unassigned in the result default to 0. The function does not care about the separators used to delimit the numeric fields in s, but does not allow more than four numeric fields. The result must also be a valid time.

If s contains the string "pm", "p.m.", or "p. m.", the hour field of the result is increased by 12.

Examples

ParseTime("11:30")
hour: 11
minute: 30
second: 0
millisecond: 0
ParseTime("11:32:20")
hour: 11
minute: 32
second: 20
millisecond: 0
ParseTime("11:32:20.215")
hour: 11
minute: 32
second: 20
millisecond: 215
ParseTime("11:32:20.215.512")
failure
Incompatible time string "11:32:20.215.512".
Call stack: ParseTime
ParseTime("11")
hour: 11
minute: 0
second: 0
millisecond: 0
ParseTime("11:50:65")
failure
Incompatible time string "11:50:65".
Call stack: ParseTime
ParseTime("7:30 pm")
hour: 19
minute: 30
second: 0
millisecond: 0
ParseTime("19:30 pm")
failure
Incompatible time string "19:30 pm".
Call stack: ParseTime

See also