Parse()

Namespace ›› System ›› MfTimeSpan ›› Methods ››
Parent Previous Next

Parse()

OutputVar := MfTimeSpan.Parse(str)

MfTimeSpan.Parse(str)

Static Method.
Converts the string representation of a time interval to its MfTimeSpan equivalent.

Parameters

str

A string that specifies the time interval to convert. Can be instance of MfString or var containing string.

Returns

Returns a time interval that corresponds to str.

Throws

Throws MfInvalidOperationException if not called as a static method.
Throws MfFormatException if str has an invalid format.
Throws MfOverflowException if represents a number that is less than MinValue or greater than MaxValue or At least one of the days, hours, minutes, or seconds components is outside its valid range.

Remarks

Static Method.
The s parameter contains a time interval specification in the form:

[ws][-]{ d | [d.]hh:mm[:ss[.ff]] }[ws]

ws - Optional white space.
- An optional minus sign, which indicates a negative MfTimeSpan.
d - Days, ranging from 0 to 10675199.
. - Seperator symbol.
hh - Hours, ranging from 0 to 23.
: - Seperator symbol.
mm - Minutes, ranging from 0 to 59.
ss - Optional seconds, ranging from 0 to 59.
. - Seperator symbol that separates seconds from fractions of a second.
ff - Optional fractional seconds, consisting of one to seven decimal digits.

The components of s must collectively specify a time interval that is greater than or equal to MinValue and less than or equal to MaxValue.

Example

span := MfTimeSpan.Parse("7")
MsgBox % span.ToString() ; Displays: 07.00:00:00

span := MfTimeSpan.Parse("7.14")
MsgBox % span.ToString() ; Displays: 07.14:00:00

span := MfTimeSpan.Parse("7.14:17")
MsgBox % span.ToString() ; Displays: 07.14:17:00

span := MfTimeSpan.Parse("7.14:17:41")
MsgBox % span.ToString() ; Displays: 07.14:17:41

span := MfTimeSpan.Parse("7.14:17:41.2434")
MsgBox % span.ToString() ; Displays: 07.14:17:41.2434000

str := new MfString("5.14:17:41")
span := MfTimeSpan.Parse(str)
MsgBox % span.ToString() ; Displays: 07.14:17:41

span := MfTimeSpan.Parse("5.14:17:41.023")
MsgBox % span.ToString() ; Displays: 05.14:17:41.0230000