Click or drag to resize

UtilHMSToHours Method

Convert sexagesimal hours to binary double-precision hours

Namespace:  ASCOM.Utilities
Assembly:  ASCOM.Utilities (in ASCOM.Utilities.dll) Version: 3c9121baba46811fe6e53a58a05935662261416d
public double HMSToHours(
	string HMS


Type: SystemString
The sexagesimal input string (hours)

Return Value

Type: Double
The double-precision binary value (hours) represented by the sexagesimal input

The sexagesimal to real conversion methods such as this one are flexible enough to convert just about anything that resembles sexagesimal. Thee way they operate is to first separate the input string into numeric "tokens", strings consisting only of the numerals 0-9, plus and minus, and period. All other characters are considered delimiters. Once the input string is parsed into tokens they are converted to numerics.

If there are more than three numeric tokens, only the first three are considered, the remainder are ignored. Left to right positionally, the tokens are assumed to represent units (degrees or hours), minutes, and seconds. If only two tokens are present, they are assumed to be units and minutes, and if only one token is present, it is assumed to be units. Any token can have a fractionsl part.

Of course it would not be normal (for example) for both the minutes and seconds parts to have fractional parts, but it would be legal. So 00:30.5:30 would convert to 1.0 unit. Note that plain units, for example 23.128734523 are acceptable to the method.

See Also