Click or drag to resize

DateTimeOffsetExtensionsParseTime Method

Parses textual time input into a DateTime.

Namespace: InnerDrive.Core
Assembly: InnerDrive.Core (in InnerDrive.Core.dll) Version: 5.0.8475.0
Syntax
C#
public static DateTimeOffset ParseTime(
	this DateTimeOffset baseDate,
	string timeText
)

Parameters

baseDate  DateTimeOffset
This DateTimeOffset.
timeText  String
The time as input by the user.

Return Value

DateTimeOffset
A DateTime containing the parsed time.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DateTimeOffset. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentExceptiontimeText is not a valid time.
ArgumentNullExceptiontimeText is null or Empty.
Remarks
timeText may contain any of the following time formats:
TextResult
10:00 AM10:00 AM
10:00 am10:00 AM
10:00 p10:00 PM
10:00p10:00 PM
1000p10:00 PM
10p10:00 PM
100010:00 PM
22:0010:00 PM
220010:00 PM
10ArgumentException
22ArgumentException
22:00 PMArgumentException
22:99ArgumentException
Example
C#
var testDate = new DateTimeOffset(2010, 11, 17, 0, 0, 0, TimeSpan.Zero);
? testDate.ParseTime("6p");

// Result: 2010-11-17 18:00:00 +00:00
See Also